From 98791845cbdeba1d8dd08a5b822d92e9a8cd6873 Mon Sep 17 00:00:00 2001 From: Andrew Childs Date: Thu, 27 Feb 2020 23:54:45 +0900 Subject: [PATCH 1/3] nixosTests.nesting: fix subtest scoping --- nixos/tests/nesting.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nixos/tests/nesting.nix b/nixos/tests/nesting.nix index 6388b67a6e40..a75806b24ff6 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( From b83164a0499475c72affebb21e7f513e7fbd0ccd Mon Sep 17 00:00:00 2001 From: Andrew Childs Date: Thu, 27 Feb 2020 23:55:21 +0900 Subject: [PATCH 2/3] nixos/activation: propagate system to nested configurations The current behavior lets `system` default to `builtins.currentSystem`. The system value specified to `eval-config.nix` has very low precedence, so this should compose properly. Fixes #80806 --- nixos/modules/system/activation/top-level.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nixos/modules/system/activation/top-level.nix b/nixos/modules/system/activation/top-level.nix index f67d29005616..346e0b64230f 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.system; modules = (optionals inheritParent modules) ++ [ ./no-clone.nix ] From ce416779bbb5d86210cbf2cc5060cc81faf53c94 Mon Sep 17 00:00:00 2001 From: Andrew Childs Date: Wed, 4 Mar 2020 23:24:22 +0900 Subject: [PATCH 3/3] nixos/activation: use eval-config's system argument for nesting 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. --- nixos/lib/eval-config.nix | 6 ++++++ nixos/modules/misc/nixpkgs.nix | 8 ++++++++ nixos/modules/system/activation/top-level.nix | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/nixos/lib/eval-config.nix b/nixos/lib/eval-config.nix index 77490ca3762a..9892d6f160f7 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 afb74581e239..011d493c1538 100644 --- a/nixos/modules/misc/nixpkgs.nix +++ b/nixos/modules/misc/nixpkgs.nix @@ -216,6 +216,14 @@ in Ignored when nixpkgs.pkgs is set. ''; }; + + initialSystem = mkOption { + type = types.str; + internal = true; + description = '' + Preserved value of system passed to eval-config.nix. + ''; + }; }; config = { diff --git a/nixos/modules/system/activation/top-level.nix b/nixos/modules/system/activation/top-level.nix index 346e0b64230f..14bd751ce324 100644 --- a/nixos/modules/system/activation/top-level.nix +++ b/nixos/modules/system/activation/top-level.nix @@ -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 ]