mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-17 11:10:03 +00:00
flake.nix: Only add _file
-key if position of args.modules
is actually known to the evaluator
This happens if the evaluator "loses" the position of an
attr-declaration[1] because of e.g. too many nested function-calls to
build the final attr-set.
While the actual issue should be fixed in Nix itself, this is IMHO a
fair workaround to unblock affected users[2].
[1] e14c245934 (commitcomment-53645936)
[2] It seems as everyone using `divnix/digga` or `flake-utils-plus`
are affected:
* https://github.com/divnix/digga/issues/87
This commit is contained in:
parent
b3d80503cf
commit
6797b92f8d
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