Skip to content

Commit

Permalink
nixos/activation: use eval-config's system argument for nesting
Browse files Browse the repository at this point in the history
This avoids a possible surprise if the user is using `nixpkgs.system`
and `nesting.children`. `nesting.children` is expected to ignore all
parent configuration so we shouldn't propagate the user-facing option
`nixpkgs.system`. To avoid doing so, we introduce a new internal
option for holding the value passed to eval-config.nix, and use that
when recursing for nesting.
  • Loading branch information
thefloweringash committed Mar 5, 2020
1 parent b83164a commit ce41677
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions nixos/lib/eval-config.nix
Expand Up @@ -41,6 +41,12 @@ let
# default to the argument. That way this new default could propagate all
# they way through, but has the last priority behind everything else.
nixpkgs.system = lib.mkDefault system;

# Stash the value of the `system` argument. When using `nesting.children`
# we want to have the same default value behavior (immediately above)
# without any interference from the user's configuration.
nixpkgs.initialSystem = system;

_module.args.pkgs = lib.mkIf (pkgs_ != null) (lib.mkForce pkgs_);
};
};
Expand Down
8 changes: 8 additions & 0 deletions nixos/modules/misc/nixpkgs.nix
Expand Up @@ -216,6 +216,14 @@ in
Ignored when <code>nixpkgs.pkgs</code> is set.
'';
};

initialSystem = mkOption {
type = types.str;
internal = true;
description = ''
Preserved value of <literal>system</literal> passed to <literal>eval-config.nix</literal>.
'';
};
};

config = {
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/system/activation/top-level.nix
Expand Up @@ -15,7 +15,7 @@ let
map (childConfig:
(import ../../../lib/eval-config.nix {
inherit baseModules;
system = config.nixpkgs.system;
system = config.nixpkgs.initialSystem;
modules =
(optionals inheritParent modules)
++ [ ./no-clone.nix ]
Expand Down

0 comments on commit ce41677

Please sign in to comment.