summaryrefslogtreecommitdiffstats
path: root/nixos/lib
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2014-05-05 15:52:33 -0400
committerNicolas B. Pierron <nicolas.b.pierron@gmail.com>2015-03-12 23:42:57 +0100
commite4a06f35b1d88ab98fa8b6962e7a3f802232d165 (patch)
tree16b61471d7378190125ab920c95ac2a340295585 /nixos/lib
parent1d62ad474694c0717017c2c8aa79909a890407b5 (diff)
nixos: Don't evaluate twice to get the value of config.nixpkgs
Diffstat (limited to 'nixos/lib')
-rw-r--r--nixos/lib/eval-config.nix35
1 files changed, 15 insertions, 20 deletions
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;