You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The nix module requires that nix.package is set (it would be helpful if the description explained why it doesn’t have a default), but the Home Manager modules for nix-darwin and NixOS set nix.package unconditionally.
I share most of my Home Manager configuration between multiple accounts and multiple machines. I had been always using home-manager explicitly, but decided to switch to the nix-darwin and NixOS modules for systems that I administer. So my configuration is loaded all three ways – home-manager, darwin-rebuild, and nixos-rebuild.
Since I have nix.packages = pkgs.nix in my shared config, this now errors when I use Home Manager as a module:
error: The option `home-manager.users.greg.nix.package' is defined multiple times while it's expected to be unique.
Definition values:
- In `<unknown-file>': <derivation nix-2.18.5>
- In `/nix/store/hxhym8c5xz6dxkl3d9yppiwlnzk3khn7-source/nixos/common.nix': <derivation nix-2.18.5>
Use `lib.mkForce value` or `lib.mkDefault value` to change the priority on any of these definitions.
The error makes sense, but I think the fix should be in Home Manager somewhere. There are a few options, in my order of preference:
make pkgs.nix the default value in modules/misc/nix.nix, which makes it less likely that a user will override it, and if they do, they can decide how they want to manage this issue;
have nixos/common.nix use lib.mkDefault, allowing the user’s setting to take precedence over the system module; or
have nixos/common.nix use lib.mkForce, ensuring that the system modue’s version always takes precedence.
Number 1 seems like the best option to me, but considering the default is explicitly set to null, I figure there’s some reason it’s not already done that way. Number 3 seems a bit ill-behaved, in that it will override what a user explicitly put in their config, so I don’t really like that. But again, the documentation doesn’t make it clear why this situation exists.
My workaround is to change nix.package = pkgs.nix to nix.package = lib.mkDefault pkgs.nix, and if that is the correct solution, it would be helpful if the docs were more descriptive.
(BTW, the channels listed by nix-info below make no sense to me. I do everything with flakes, and when I run nix-channel --list, there are no channels listed.)
Maintainer CC
I see no explicit mantainers on either modules/misc/nix.nix or nixos/common.nix, but @rycee (unsurprisingly) touched both recently.
Are you following the right branch?
Is there an existing issue for this?
Issue description
The
nix
module requires thatnix.package
is set (it would be helpful if the description explained why it doesn’t have a default), but the Home Manager modules for nix-darwin and NixOS setnix.package
unconditionally.I share most of my Home Manager configuration between multiple accounts and multiple machines. I had been always using
home-manager
explicitly, but decided to switch to the nix-darwin and NixOS modules for systems that I administer. So my configuration is loaded all three ways –home-manager
,darwin-rebuild
, andnixos-rebuild
.Since I have
nix.packages = pkgs.nix
in my shared config, this now errors when I use Home Manager as a module:The error makes sense, but I think the fix should be in Home Manager somewhere. There are a few options, in my order of preference:
pkgs.nix
the default value in modules/misc/nix.nix, which makes it less likely that a user will override it, and if they do, they can decide how they want to manage this issue;lib.mkDefault
, allowing the user’s setting to take precedence over the system module; orlib.mkForce
, ensuring that the system modue’s version always takes precedence.Number 1 seems like the best option to me, but considering the default is explicitly set to
null
, I figure there’s some reason it’s not already done that way. Number 3 seems a bit ill-behaved, in that it will override what a user explicitly put in their config, so I don’t really like that. But again, the documentation doesn’t make it clear why this situation exists.My workaround is to change
nix.package = pkgs.nix
tonix.package = lib.mkDefault pkgs.nix
, and if that is the correct solution, it would be helpful if the docs were more descriptive.(BTW, the channels listed by
nix-info
below make no sense to me. I do everything with flakes, and when I runnix-channel --list
, there are no channels listed.)Maintainer CC
I see no explicit mantainers on either modules/misc/nix.nix or nixos/common.nix, but @rycee (unsurprisingly) touched both recently.
System information
The text was updated successfully, but these errors were encountered: