nix flake check fails with overlays because arguments are not properly named
mitchellh opened this issue · 2 comments
mitchellh commented
Describe the bug
If you specify an overlay
attribute when using flake-utils.lib.eachSystem
, nix flake check
will fail because the final overlay attribute has invalid argument names.
To Reproduce
Steps to reproduce the behavior:
- Create a flake with an overlay
- Run
nix flake check
My flake is roughly this:
{
outputs = { self, nixpkgs, flake-utils, ... }@inputs:
flake-utils.lib.eachSystem ["aarch64-linux" "x86_64-linux"] (system: {
# ... other stuff
overlay = final: prev: {
foo = packages.foo;
};
}
);
}
Error:
$ nix flake check --show-trace
error: overlay does not take an argument named 'final'
… while checking the overlay 'overlay'
at /nix/store/kfpqwqdzm3rf153hr63hp4v81xbm5bx4-source/default.nix:75:15:
74| {
75| ${key} = (attrs.${key} or { }) // (if key == "hydraJobs"
| ^
76| then builtins.mapAttrs (name: value: (attrs.hydraJobs.${name} or { }) // { ${system} = value; }) ret.hydraJobs
… while checking flake output 'overlay'
at /nix/store/kfpqwqdzm3rf153hr63hp4v81xbm5bx4-source/default.nix:75:15:
74| {
75| ${key} = (attrs.${key} or { }) // (if key == "hydraJobs"
| ^
76| then builtins.mapAttrs (name: value: (attrs.hydraJobs.${name} or { }) // { ${system} = value; }) ret.hydraJobs
Expected behavior
nix flake check
should pass.
Additional Context
$ nix --version
nix (Nix) 2.5pre20211007_844dd90
zimbatm commented
eachSystem
is just for the attributes that are organized by <attr>.<system>
. You can merge it with the other ones like that:
{
outputs = { self, nixpkgs, flake-utils, ... }@inputs:
(flake-utils.lib.eachSystem ["aarch64-linux" "x86_64-linux"] (system: {
# ... other stuff
}
)) // {
overlay = final: prev: {
foo = packages.foo;
};
};
}
mitchellh commented
Got it thanks!