diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2018-05-17 18:53:13 -0400 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2018-09-07 16:43:56 -0400 |
commit | 9f9723b179961e7235d8e808c4ee8eaf52e05086 (patch) | |
tree | 195a13e5812ae28dac6e2a367309b72fd7dc3b2a /nixos/modules | |
parent | 8ae27030aa4989d42f9335d4b80a5a4d3d6d039c (diff) | |
download | nixpkgs-9f9723b179961e7235d8e808c4ee8eaf52e05086.tar nixpkgs-9f9723b179961e7235d8e808c4ee8eaf52e05086.tar.gz nixpkgs-9f9723b179961e7235d8e808c4ee8eaf52e05086.tar.bz2 nixpkgs-9f9723b179961e7235d8e808c4ee8eaf52e05086.tar.lz nixpkgs-9f9723b179961e7235d8e808c4ee8eaf52e05086.tar.xz nixpkgs-9f9723b179961e7235d8e808c4ee8eaf52e05086.tar.zst nixpkgs-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/modules')
-rw-r--r-- | nixos/modules/misc/nixpkgs.nix | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/nixos/modules/misc/nixpkgs.nix b/nixos/modules/misc/nixpkgs.nix index 8fbe218b232..7f9833e184a 100644 --- a/nixos/modules/misc/nixpkgs.nix +++ b/nixos/modules/misc/nixpkgs.nix @@ -62,12 +62,11 @@ in pkgs = mkOption { defaultText = literalExample ''import "''${nixos}/.." { - inherit (config.nixpkgs) config overlays localSystem crossSystem; + inherit (cfg) config overlays localSystem crossSystem; } ''; default = import ../../.. { - localSystem = { inherit (cfg) system; } // cfg.localSystem; - inherit (cfg) config overlays crossSystem; + inherit (cfg) config overlays localSystem crossSystem; }; type = pkgsType; example = literalExample ''import <nixpkgs> {}''; @@ -140,8 +139,11 @@ in localSystem = mkOption { type = types.attrs; # TODO utilize lib.systems.parsedPlatform - default = { system = builtins.currentSystem; }; + default = { inherit (cfg) system; }; example = { system = "aarch64-linux"; config = "aarch64-unknown-linux-gnu"; }; + # Make sure that the final value has all fields for sake of other modules + # referring to this. TODO make `lib.systems` itself use the module system. + apply = lib.systems.elaborate; defaultText = literalExample ''(import "''${nixos}/../lib").lib.systems.examples.aarch64-multiplatform''; description = '' @@ -180,6 +182,7 @@ in system = mkOption { type = types.str; example = "i686-linux"; + default = { system = builtins.currentSystem; }; description = '' Specifies the Nix platform type on which NixOS should be built. It is better to specify <code>nixpkgs.localSystem</code> instead. @@ -196,6 +199,7 @@ in </programlisting> See <code>nixpkgs.localSystem</code> for more information. + Ignored when <code>nixpkgs.localSystem</code> is set. Ignored when <code>nixpkgs.pkgs</code> is set. ''; }; |