Merge pull request #130570 from Ma27/flake-pos-eval-error
flake.nix: Only add `_file`-key if position of `args.modules` is actually know to the evaluator
This commit is contained in:
commit
6564e7ef13
1 changed files with 8 additions and 2 deletions
10
flake.nix
10
flake.nix
|
@ -49,12 +49,18 @@
|
|||
})).config;
|
||||
|
||||
moduleDeclarationFile =
|
||||
(builtins.unsafeGetAttrPos "modules" args).file;
|
||||
let
|
||||
# Even though `modules` is a mandatory argument for `nixosSystem`, it doesn't
|
||||
# mean that the evaluator always keeps track of its position. If there
|
||||
# are too many levels of indirection, the position gets lost at some point.
|
||||
intermediatePos = builtins.unsafeGetAttrPos "modules" args;
|
||||
in
|
||||
if intermediatePos == null then null else intermediatePos.file;
|
||||
|
||||
# Add the invoking file as error message location for modules
|
||||
# that don't have their own locations; presumably inline modules.
|
||||
addModuleDeclarationFile =
|
||||
m: {
|
||||
m: if moduleDeclarationFile == null then m else {
|
||||
_file = moduleDeclarationFile;
|
||||
imports = [ m ];
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue