summary refs log tree commit diff
path: root/nixos/modules/misc/nixpkgs.nix
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-05-17 18:53:13 -0400
commit4fe289860888668956b7e79e24efeb101c2f51d1 (patch)
tree9e6788604f66e95fbebc11f8d2f6b784a2a3d16c /nixos/modules/misc/nixpkgs.nix
parentf3fcf1b0a9b0398620b5fa9b40268ef651aa373e (diff)
downloadnixpkgs-4fe289860888668956b7e79e24efeb101c2f51d1.tar
nixpkgs-4fe289860888668956b7e79e24efeb101c2f51d1.tar.gz
nixpkgs-4fe289860888668956b7e79e24efeb101c2f51d1.tar.bz2
nixpkgs-4fe289860888668956b7e79e24efeb101c2f51d1.tar.lz
nixpkgs-4fe289860888668956b7e79e24efeb101c2f51d1.tar.xz
nixpkgs-4fe289860888668956b7e79e24efeb101c2f51d1.tar.zst
nixpkgs-4fe289860888668956b7e79e24efeb101c2f51d1.zip
nixpkgs module: Fix defaulting of `localSystem` and `system`
My c6f7d4367894047592cc412740f0c1f5b2ca2b59 made the mistake of not
having enough defaults. Now both variables are default as the *explicit*
value of the other, or a fallback. The fallback of `system` is the
default of `localSystem.system`. The fallback of `localSystem` is not
the other default (projected), as that would cause a cycle, but `{
system = builtins.currentTime; }` just as nixpkgs itself does it.
Diffstat (limited to 'nixos/modules/misc/nixpkgs.nix')
-rw-r--r--nixos/modules/misc/nixpkgs.nix13
1 files changed, 8 insertions, 5 deletions
diff --git a/nixos/modules/misc/nixpkgs.nix b/nixos/modules/misc/nixpkgs.nix
index 8fbe218b232..29019ed3d55 100644
--- a/nixos/modules/misc/nixpkgs.nix
+++ b/nixos/modules/misc/nixpkgs.nix
@@ -1,9 +1,10 @@
-{ config, lib, pkgs, ... }:
+{ config, options, lib, pkgs, ... }:
 
 with lib;
 
 let
   cfg = config.nixpkgs;
+  opts = options.nixpgs;
 
   isConfig = x:
     builtins.isAttrs x || lib.isFunction x;
@@ -62,12 +63,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,7 +140,7 @@ in
 
     localSystem = mkOption {
       type = types.attrs; # TODO utilize lib.systems.parsedPlatform
-      default = { system = builtins.currentSystem; };
+      default = { system = cfg.system or builtins.currentSystem; };
       example = { system = "aarch64-linux"; config = "aarch64-unknown-linux-gnu"; };
       defaultText = literalExample
         ''(import "''${nixos}/../lib").lib.systems.examples.aarch64-multiplatform'';
@@ -179,6 +179,8 @@ in
 
     system = mkOption {
       type = types.str;
+      default = cfg.localSystem.system
+        or opts.localSystem.default.system;
       example = "i686-linux";
       description = ''
         Specifies the Nix platform type on which NixOS should be built.
@@ -196,6 +198,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.
       '';
     };