1
0
Fork 0
mirror of https://github.com/hercules-ci/flake-parts.git synced 2024-12-14 11:47:31 +00:00

mkFlake: Prefer unsafeGetAttrPos over self.outPath for error message

This would not be advisable for anything other than error messages,
because Nix does not commit to any semantics for that function.
This commit is contained in:
Robert Hensing 2023-10-13 23:02:24 +02:00
parent f359432597
commit fc74939824

11
lib.nix
View file

@ -121,14 +121,17 @@ let
mkFlake = args: module: mkFlake = args: module:
let let
loc = inputsPos = builtins.unsafeGetAttrPos "inputs" args;
moduleLocation =
args.moduleLocation or ( args.moduleLocation or (
if args?inputs.self.outPath if inputsPos != null
then inputsPos.file
else if args?inputs.self.outPath
then args.inputs.self.outPath + "/flake.nix" then args.inputs.self.outPath + "/flake.nix"
else "<mkFlake argument>" else "<mkFlake argument>"
); );
mod = lib.setDefaultModuleLocation loc module; mod = lib.setDefaultModuleLocation moduleLocation module;
eval = flake-parts-lib.evalFlakeModule args mod; eval = flake-parts-lib.evalFlakeModule (args // { inherit moduleLocation; }) mod;
in in
eval.config.flake; eval.config.flake;