nix-darwin
nix-darwin copied to clipboard
Evaluation failure using flakes and using nixpkgs release-20.03
If I use the 20.03 release, there is an evaluation error when building this system:
{
inputs = {
nixpkgs.url = "git+https://github.com/nixos/nixpkgs?ref=release-20.03";
darwin.url = "github:LnL7/nix-darwin";
};
outputs = { self, darwin, nixpkgs, ... }: {
darwinConfigurations.my-hostname = let system = "x86_64-darwin"; in
darwin.lib.darwinSystem {
inherit system;
modules = [{ nixpkgs = import nixpkgs { inherit system; }; }];
};
};
}
{
"nodes": {
"darwin": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1634994402,
"narHash": "sha256-xmlCVVOYGpZoxgOqsDOVF0B0ASrnbNGVAEzID9qh2xo=",
"owner": "LnL7",
"repo": "nix-darwin",
"rev": "44da835ac40dab5fd231298b59d83487382d2fab",
"type": "github"
},
"original": {
"owner": "LnL7",
"repo": "nix-darwin",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1602411953,
"narHash": "sha256-gbupmxRpoQZqL5NBQCJN2GI5G7XDEHHHYKhVwEj5+Ps=",
"owner": "LnL7",
"repo": "nixpkgs",
"rev": "f780534ea2d0c12e62607ff254b6b45f46653f7a",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1625876338,
"narHash": "sha256-pys6cebTmrZ7FHT4JUAFl4wk2IBff9aDE3hD6BcPYho=",
"ref": "release-20.03",
"rev": "eb73405ecceb1dc505b7cbbd234f8f94165e2696",
"revCount": 216226,
"type": "git",
"url": "https://github.com/nixos/nixpkgs"
},
"original": {
"ref": "release-20.03",
"type": "git",
"url": "https://github.com/nixos/nixpkgs"
}
},
"root": {
"inputs": {
"darwin": "darwin",
"nixpkgs": "nixpkgs_2"
}
}
},
"root": "root",
"version": 7
}
$ nix build -L --show-trace .#darwinConfigurations.my-hostname.system
error: The option `nixpkgs.AAAAAASomeThingsFailToEvaluate' does not exist. Definition values:
- In `<unknown-file>'
… while evaluating 'evalModules'
at /nix/store/bq10m17mq4si9m2ai5h06b9zc27bbn3r-source/lib/modules.nix:21:17:
20| evalModules) and the less declarative the module set is. */
21| evalModules = { modules
| ^
22| , prefix ? []
… from call site
at /nix/store/g7kjd5mkr6g2yydcrm1l8iih13gpwq0d-source/eval-config.nix:35:10:
34|
35| eval = libExtended.evalModules (builtins.removeAttrs args [ "inputs" "system" ] // {
| ^
36| modules = modules ++ [ inputsModule pkgsModule ] ++ baseModules;
I would love to use nix-darwin but we have an old revision of nixpkgs we unfortunately have to use. If nix-darwin does not support 20.0x (or some other revision), it would be nice to know, at least.
(sorry for my tone, I totally forgot how experimental flakes are) I guess I am going to learn about nixos module internals now! :)
Looks like the issue is the deprecated check
attribute of evalModules
in nixpkgs. I'm not sure if this is a documentation issue, or something else. (see https://github.com/NixOS/nixpkgs/blob/9e8961e5607402ed0ff98e283ef485ac8f22e226/lib/modules.nix#L88)
Using 20.0x, adding the attribute to the darwin configuration fixed my issue. i.e.:
{
inputs = {
nixpkgs.url = "git+https://github.com/nixos/nixpkgs?ref=release-20.03";
darwin.url = "github:LnL7/nix-darwin";
};
outputs = { self, darwin, nixpkgs, ... }: {
darwinConfigurations.my-hostname = let system = "x86_64-darwin"; in
darwin.lib.darwinSystem {
inherit system;
modules = [{ nixpkgs = import nixpkgs { inherit system; }; }];
check = false;
};
};
}
The current expressions seems to be kind of geared towards flakes, but also not really using flakes as intended.
Initializing pkgs
is currently a mess in the whole ecosystem. I don't think any single module can do a good job at it. I think we should cut it out, but the next best thing is to use lib.mkForce
.
You could try adding a module { config._module.args.pkgs = lib.mkForce (import nixpkgs { system = "x86_64-darwin"; }); }
for example.
If you want to override nixpkgs from a flake, the correct way to do this is to pass it in as inputs
. This would look like
{
inputs = {
nixpkgs.url = "git+https://github.com/nixos/nixpkgs?ref=release-20.03";
darwin.url = "github:LnL7/nix-darwin";
};
outputs = { self, darwin, nixpkgs, ... }: {
darwinConfigurations.my-hostname = let system = "x86_64-darwin"; in
darwin.lib.darwinSystem {
inherit system;
modules = [ /* where's your config module? */ ];
inputs = { inherit nixpkgs; };
};
};
}
This way your config.nixpkgs
will continue to work as well.
You can simplify this slightly by just passing all of your inputs too, like so:
{
inputs = {
nixpkgs.url = "git+https://github.com/nixos/nixpkgs?ref=release-20.03";
darwin.url = "github:LnL7/nix-darwin";
};
outputs = { self, darwin, nixpkgs, ... }@inputs: {
darwinConfigurations.my-hostname = let system = "x86_64-darwin"; in
darwin.lib.darwinSystem {
inherit system inputs;
modules = [ /* where's your config module? */ ];
};
};
}
Hey @jsoo1, I was looking into why we have this option in eval-config.nix
. Do you know how https://github.com/LnL7/nix-darwin/pull/397/commits/cb1b24cff1e5fc682785952127aa530bf9322d29 fixed this issue? It's unclear to me how adding an unused parameter to our eval-config.nix
would stop the nixpkgs.AAAAAASomeThingsFailToEvaluate
error.
Hm. I'm not sure anymore! I won't be mad if it gets removed. We have definitely moved on from 20.x releases and I am not sure it's worth supporting them any longer.