summary refs log tree commit diff
path: root/nixos/lib
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2018-05-17 18:53:13 -0400
committerJohn Ericson <John.Ericson@Obsidian.Systems>2018-09-07 16:43:56 -0400
commit9f9723b179961e7235d8e808c4ee8eaf52e05086 (patch)
tree195a13e5812ae28dac6e2a367309b72fd7dc3b2a /nixos/lib
parent8ae27030aa4989d42f9335d4b80a5a4d3d6d039c (diff)
downloadnixlib-9f9723b179961e7235d8e808c4ee8eaf52e05086.tar
nixlib-9f9723b179961e7235d8e808c4ee8eaf52e05086.tar.gz
nixlib-9f9723b179961e7235d8e808c4ee8eaf52e05086.tar.bz2
nixlib-9f9723b179961e7235d8e808c4ee8eaf52e05086.tar.lz
nixlib-9f9723b179961e7235d8e808c4ee8eaf52e05086.tar.xz
nixlib-9f9723b179961e7235d8e808c4ee8eaf52e05086.tar.zst
nixlib-9f9723b179961e7235d8e808c4ee8eaf52e05086.zip
nixpkgs module: Fix defaulting of `localSystem` and `system`
Take two of #40708 (4fe289860888668956b7e79e24efeb101c2f51d1).

That PR attempted to bidirectionally default `config.nixpkgs.system` and
`config.nixpkgs.localSystem.system` to each be updated by the other. But
this is not possible with the way the module system works. Divergence in
certain cases in inevitable.

This PR is more conservative and just has `system` default `localSystem`
and `localSystem` make the final call as-is. This solves a number of
issues.

 - `localSystem` completely overrides `system`, just like with nixpkgs
 proper. There is no need to specify `localSystem.system` to clobber the
 old system.

 - `config.nixpkgs.localSystem` is exactly what is passed to nixpkgs. No
 spooky steps.

 - `config.nixpkgs.localSystem` is elaborated just as nixpkgs would so
 that all attributes are available, not just the ones the user
 specified.

The remaining issue is just that `config.nixpkgs.system` doesn't update
based on `config.nixpkgs.localSystem.system`. It should never be
referred to lest it is a bogus stale value because
`config.nixpkgs.localSystem` overwrites it.

Fixes #46320
Diffstat (limited to 'nixos/lib')
-rw-r--r--nixos/lib/eval-config.nix6
1 files changed, 5 insertions, 1 deletions
diff --git a/nixos/lib/eval-config.nix b/nixos/lib/eval-config.nix
index 97c79487df4c..ef685949ae1f 100644
--- a/nixos/lib/eval-config.nix
+++ b/nixos/lib/eval-config.nix
@@ -36,7 +36,11 @@ let
     _file = ./eval-config.nix;
     key = _file;
     config = {
-      nixpkgs.localSystem = lib.mkDefault { inherit system; };
+      # Explicit `nixpkgs.system` or `nixpkgs.localSystem` should override
+      # this.  Since the latter defaults to the former, the former should
+      # 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;
       _module.args.pkgs = lib.mkIf (pkgs_ != null) (lib.mkForce pkgs_);
     };
   };