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:
parent
f359432597
commit
fc74939824
1 changed files with 7 additions and 4 deletions
11
lib.nix
11
lib.nix
|
@ -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;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue