diff options
author | Maximilian Bosch <maximilian@mbosch.me> | 2021-07-18 19:09:38 +0200 |
---|---|---|
committer | Maximilian Bosch <maximilian@mbosch.me> | 2021-07-18 19:47:10 +0200 |
commit | 6797b92f8d0f357702da4f13cf69bcd43e006240 (patch) | |
tree | cf76684cba584f9ea855266b43043335354f1cd0 /flake.nix | |
parent | b3d80503cfa3e5b8513d47f91ac1a2025e81141c (diff) | |
download | nixpkgs-6797b92f8d0f357702da4f13cf69bcd43e006240.tar nixpkgs-6797b92f8d0f357702da4f13cf69bcd43e006240.tar.gz nixpkgs-6797b92f8d0f357702da4f13cf69bcd43e006240.tar.bz2 nixpkgs-6797b92f8d0f357702da4f13cf69bcd43e006240.tar.lz nixpkgs-6797b92f8d0f357702da4f13cf69bcd43e006240.tar.xz nixpkgs-6797b92f8d0f357702da4f13cf69bcd43e006240.tar.zst nixpkgs-6797b92f8d0f357702da4f13cf69bcd43e006240.zip |
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] https://github.com/NixOS/nixpkgs/commit/e14c24593420bb9057e7f38b40d17137eaeff9dd#commitcomment-53645936 [2] It seems as everyone using `divnix/digga` or `flake-utils-plus` are affected: * https://github.com/divnix/digga/issues/87
Diffstat (limited to 'flake.nix')
-rw-r--r-- | flake.nix | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/flake.nix b/flake.nix index 92c0d97c4a2..ececd26c153 100644 --- a/flake.nix +++ b/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 ]; }; |