diff options
author | Michele Guerini Rocco <rnhmjoj@users.noreply.github.com> | 2020-03-13 09:58:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-13 09:58:10 +0100 |
commit | 7b15d6cee4839c5ef2e3a9fea355b6007f008820 (patch) | |
tree | 58fab3d31d9b48cfda31cbaa4113f1dd6d3e43c3 /nixos | |
parent | b6ae8193edd5fb5188565d6163c86e76a096a500 (diff) | |
parent | ce416779bbb5d86210cbf2cc5060cc81faf53c94 (diff) |
Merge pull request #81241 from thefloweringash/nesting-system
nixos/activation: propagate system to nested configurations
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/lib/eval-config.nix | 6 | ||||
-rw-r--r-- | nixos/modules/misc/nixpkgs.nix | 8 | ||||
-rw-r--r-- | nixos/modules/system/activation/top-level.nix | 1 | ||||
-rw-r--r-- | nixos/tests/nesting.nix | 8 |
4 files changed, 19 insertions, 4 deletions
diff --git a/nixos/lib/eval-config.nix b/nixos/lib/eval-config.nix index 77490ca3762a5..9892d6f160f7f 100644 --- a/nixos/lib/eval-config.nix +++ b/nixos/lib/eval-config.nix @@ -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_); }; }; diff --git a/nixos/modules/misc/nixpkgs.nix b/nixos/modules/misc/nixpkgs.nix index afb74581e2398..011d493c15388 100644 --- a/nixos/modules/misc/nixpkgs.nix +++ b/nixos/modules/misc/nixpkgs.nix @@ -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 = { diff --git a/nixos/modules/system/activation/top-level.nix b/nixos/modules/system/activation/top-level.nix index f67d290056169..14bd751ce3246 100644 --- a/nixos/modules/system/activation/top-level.nix +++ b/nixos/modules/system/activation/top-level.nix @@ -15,6 +15,7 @@ let map (childConfig: (import ../../../lib/eval-config.nix { inherit baseModules; + system = config.nixpkgs.initialSystem; modules = (optionals inheritParent modules) ++ [ ./no-clone.nix ] diff --git a/nixos/tests/nesting.nix b/nixos/tests/nesting.nix index 6388b67a6e403..a75806b24ff6e 100644 --- a/nixos/tests/nesting.nix +++ b/nixos/tests/nesting.nix @@ -29,10 +29,10 @@ import ./make-test-python.nix { ) clone.succeed("cowsay hey") clone.succeed("hello") - - children.wait_for_unit("default.target") - children.succeed("cowsay hey") - children.fail("hello") + + children.wait_for_unit("default.target") + children.succeed("cowsay hey") + children.fail("hello") with subtest("Nested children do not inherit from parent"): children.succeed( |