summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--nixos/lib/eval-config.nix20
-rw-r--r--nixos/modules/misc/extra-arguments.nix14
-rw-r--r--nixos/modules/misc/nixpkgs.nix9
-rw-r--r--nixos/modules/module-list.nix1
4 files changed, 27 insertions, 17 deletions
diff --git a/nixos/lib/eval-config.nix b/nixos/lib/eval-config.nix
index b4b251d2581..a157ffd5695 100644
--- a/nixos/lib/eval-config.nix
+++ b/nixos/lib/eval-config.nix
@@ -35,6 +35,7 @@ let
     key = _file;
     config = {
       nixpkgs.system = lib.mkDefault system_;
+      __internal.args.pkgs = lib.mkIf (pkgs_ != null) (lib.mkForce pkgs_);
     };
   };
 
@@ -56,23 +57,8 @@ in rec {
   # the 64-bit package anyway. However, it would be cleaner to respect
   # nixpkgs.config here.
   extraArgs = extraArgs_ // {
-    inherit pkgs modules baseModules;
-    modulesPath = ../modules;
-    pkgs_i686 = import ./nixpkgs.nix { system = "i686-linux"; config.allowUnfree = true; };
-    utils = import ./utils.nix pkgs;
+    inherit modules baseModules;
   };
 
-  pkgs =
-    if pkgs_ != null
-    then pkgs_
-    else import ./nixpkgs.nix (
-      let
-        system = if nixpkgsOptions.system != "" then nixpkgsOptions.system else system_;
-        nixpkgsOptions = config.nixpkgs;
-      in
-      {
-        inherit system;
-        inherit (nixpkgsOptions) config;
-      });
-
+  inherit (config.__internal.args) pkgs;
 }
diff --git a/nixos/modules/misc/extra-arguments.nix b/nixos/modules/misc/extra-arguments.nix
new file mode 100644
index 00000000000..9943a6192a6
--- /dev/null
+++ b/nixos/modules/misc/extra-arguments.nix
@@ -0,0 +1,14 @@
+{ lib, pkgs, config, ... }:
+
+{
+  __internal.args = {
+    modulesPath = ../.;
+
+    pkgs_i686 = import ../../lib/nixpkgs.nix {
+      system = "i686-linux";
+      config.allowUnfree = true;
+    };
+
+    utils = import ../../lib/utils.nix pkgs;
+  };
+}
diff --git a/nixos/modules/misc/nixpkgs.nix b/nixos/modules/misc/nixpkgs.nix
index cbb42c00003..2b648c1fa4e 100644
--- a/nixos/modules/misc/nixpkgs.nix
+++ b/nixos/modules/misc/nixpkgs.nix
@@ -60,6 +60,7 @@ in
 
     nixpkgs.system = mkOption {
       type = types.str;
+      default = builtins.currentSystem;
       description = ''
         Specifies the Nix platform type for which NixOS should be built.
         If unset, it defaults to the platform type of your host system.
@@ -69,4 +70,12 @@ in
     };
 
   };
+
+  config = {
+    __internal.args.pkgs = import ../../lib/nixpkgs.nix {
+      system = config.nixpkgs.system;
+
+      inherit (config.nixpkgs) config;
+    };
+  };
 }
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 95337168d10..7a324a2bb30 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -44,6 +44,7 @@
   ./installer/tools/tools.nix
   ./misc/assertions.nix
   ./misc/crashdump.nix
+  ./misc/extra-arguments.nix
   ./misc/ids.nix
   ./misc/lib.nix
   ./misc/locate.nix