about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--lib/modules.nix4
-rw-r--r--nixos/lib/eval-config.nix35
-rw-r--r--nixos/modules/misc/nixpkgs.nix4
-rw-r--r--nixos/modules/system/boot/systemd.nix2
4 files changed, 18 insertions, 27 deletions
diff --git a/lib/modules.nix b/lib/modules.nix
index b514544c1e08..84ca209d3671 100644
--- a/lib/modules.nix
+++ b/lib/modules.nix
@@ -12,10 +12,10 @@ rec {
      and ‘config’: the nested set of all option values. */
   evalModules = { modules, prefix ? [], args ? {}, check ? true }:
     let
-      internalModule = {
+      internalModule = rec {
         _file = ./modules.nix;
 
-        key = ./modules.nix;
+        key = _file;
 
         options = {
           __internal.args = mkOption {
diff --git a/nixos/lib/eval-config.nix b/nixos/lib/eval-config.nix
index 08adcf3a0078..460f5601ae76 100644
--- a/nixos/lib/eval-config.nix
+++ b/nixos/lib/eval-config.nix
@@ -9,18 +9,30 @@
 , modules
 , check ? true
 , prefix ? []
+, lib ? import ../../lib
 }:
 
 let extraArgs_ = extraArgs; pkgs_ = pkgs; system_ = system;
     extraModules = let e = builtins.getEnv "NIXOS_EXTRA_MODULE_PATH";
                    in if e == "" then [] else [(import (builtins.toPath e))];
+in
+
+let
+  pkgsModule = rec {
+    _file = ./eval-config.nix;
+    key = _file;
+    config = {
+      nixpkgs.system = lib.mkDefault system_;
+    };
+  };
+
 in rec {
 
   # Merge the option definitions in all modules, forming the full
   # system configuration.
-  inherit (pkgs.lib.evalModules {
+  inherit (lib.evalModules {
     inherit prefix;
-    modules = modules ++ extraModules ++ baseModules;
+    modules = modules ++ extraModules ++ baseModules ++ [ pkgsModule ];
     args = extraArgs;
     check = check && options.environment.checkConfigurationOptions.value;
   }) config options;
@@ -39,30 +51,13 @@ in rec {
     utils = import ./utils.nix pkgs;
   };
 
-  # Import Nixpkgs, allowing the NixOS option nixpkgs.config to
-  # specify the Nixpkgs configuration (e.g., to set package options
-  # such as firefox.enableGeckoMediaPlayer, or to apply global
-  # overrides such as changing GCC throughout the system), and the
-  # option nixpkgs.system to override the platform type.  This is
-  # tricky, because we have to prevent an infinite recursion: "pkgs"
-  # is passed as an argument to NixOS modules, but the value of "pkgs"
-  # depends on config.nixpkgs.config, which we get from the modules.
-  # So we call ourselves here with "pkgs" explicitly set to an
-  # instance that doesn't depend on nixpkgs.config.
   pkgs =
     if pkgs_ != null
     then pkgs_
     else import ./nixpkgs.nix (
       let
         system = if nixpkgsOptions.system != "" then nixpkgsOptions.system else system_;
-        nixpkgsOptions = (import ./eval-config.nix {
-          inherit system extraArgs modules prefix;
-          # For efficiency, leave out most NixOS modules; they don't
-          # define nixpkgs.config, so it's pointless to evaluate them.
-          baseModules = [ ../modules/misc/nixpkgs.nix ../modules/config/no-x-libs.nix ];
-          pkgs = import ./nixpkgs.nix { system = system_; config = {}; };
-          check = false;
-        }).config.nixpkgs;
+        nixpkgsOptions = config.nixpkgs;
       in
       {
         inherit system;
diff --git a/nixos/modules/misc/nixpkgs.nix b/nixos/modules/misc/nixpkgs.nix
index f41c8817ba4a..cbb42c000039 100644
--- a/nixos/modules/misc/nixpkgs.nix
+++ b/nixos/modules/misc/nixpkgs.nix
@@ -69,8 +69,4 @@ in
     };
 
   };
-
-  config = {
-    nixpkgs.system = mkDefault pkgs.stdenv.system;
-  };
 }
diff --git a/nixos/modules/system/boot/systemd.nix b/nixos/modules/system/boot/systemd.nix
index f853a8f6775c..f3ffda023675 100644
--- a/nixos/modules/system/boot/systemd.nix
+++ b/nixos/modules/system/boot/systemd.nix
@@ -1,7 +1,7 @@
 { config, lib, pkgs, utils, ... }:
 
-with lib;
 with utils;
+with lib;
 with import ./systemd-unit-options.nix { inherit config lib; };
 
 let