Skip to content

Commit

Permalink
Align overriding of nixpkgs.pkgs
Browse files Browse the repository at this point in the history
Previously setting `nixpkgs.pkgs` twice (in base layer and live system
definition) worked, somehow. With nixpkgs for 23.05, this led to a
failure during evaluation:

    error: The option `nixpkgs.pkgs' is defined multiple times while it's expected to be unique.
       A Nixpkgs pkgs set can not be merged with another pkgs set.
       Definition values:
       - In `/nix/store/hl93xdyddynkvgpvfpvyvy1qvw0jvf11-source/nixos/default.nix'
       - In `/nix/store/hl93xdyddynkvgpvfpvyvy1qvw0jvf11-source/nixos/default.nix'
       Use `lib.mkForce value` or `lib.mkDefault value` to change the priority on any of these definitions.

We can avoid this issue by setting the override only in the base
definition, it does not need to be repeated in the live system
definition. Using `mkDefault` for the definition in the base layer as
recommended in the option's documentation[^1].

The installer system does not rely on the base layer and only refers to
it via an already built disk image. But we do not need to override the
`pkgs` property in it at all, so we leave the property unset.

[^1]: https://search.nixos.org/options?channel=23.05&show=nixpkgs.pkgs&from=0&size=50&sort=relevance&type=packages&query=nixpkgs.pkgs
  • Loading branch information
knuton committed Sep 4, 2023
1 parent f10d632 commit 33d837b
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 8 deletions.
3 changes: 1 addition & 2 deletions base/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ with lib;
};

config = {

# Use overlayed pkgs.
nixpkgs.pkgs = pkgs;
nixpkgs.pkgs = lib.mkDefault pkgs;

# Custom label when identifying OS
system.nixos.label = "${safeProductName}-${version}";
Expand Down
3 changes: 0 additions & 3 deletions installer/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
with lib;

{
# Force use of already overlayed nixpkgs in modules
nixpkgs.pkgs = pkgs;

imports = [
(pkgs.importFromNixos "modules/installer/cd-dvd/iso-image.nix")
];
Expand Down
3 changes: 0 additions & 3 deletions live/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ let nixos = pkgs.importFromNixos ""; in
];

config = {
# Force use of already overlayed nixpkgs in modules
nixpkgs.pkgs = pkgs;

# ISO image customization
isoImage.makeEfiBootable = true;
isoImage.makeUsbBootable = true;
Expand Down

0 comments on commit 33d837b

Please sign in to comment.