forked from mirrors/nixpkgs
nixos: Don't evaluate twice to get the value of config.nixpkgs
This commit is contained in:
parent
1d62ad4746
commit
e4a06f35b1
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -69,8 +69,4 @@ in
|
|||
};
|
||||
|
||||
};
|
||||
|
||||
config = {
|
||||
nixpkgs.system = mkDefault pkgs.stdenv.system;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{ config, lib, pkgs, utils, ... }:
|
||||
|
||||
with lib;
|
||||
with utils;
|
||||
with lib;
|
||||
with import ./systemd-unit-options.nix { inherit config lib; };
|
||||
|
||||
let
|
||||
|
|
Loading…
Reference in a new issue