mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-27 05:43:50 +03:00
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. */
|
and ‘config’: the nested set of all option values. */
|
||||||
evalModules = { modules, prefix ? [], args ? {}, check ? true }:
|
evalModules = { modules, prefix ? [], args ? {}, check ? true }:
|
||||||
let
|
let
|
||||||
internalModule = {
|
internalModule = rec {
|
||||||
_file = ./modules.nix;
|
_file = ./modules.nix;
|
||||||
|
|
||||||
key = ./modules.nix;
|
key = _file;
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
__internal.args = mkOption {
|
__internal.args = mkOption {
|
||||||
|
@ -9,18 +9,30 @@
|
|||||||
, modules
|
, modules
|
||||||
, check ? true
|
, check ? true
|
||||||
, prefix ? []
|
, prefix ? []
|
||||||
|
, lib ? import ../../lib
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let extraArgs_ = extraArgs; pkgs_ = pkgs; system_ = system;
|
let extraArgs_ = extraArgs; pkgs_ = pkgs; system_ = system;
|
||||||
extraModules = let e = builtins.getEnv "NIXOS_EXTRA_MODULE_PATH";
|
extraModules = let e = builtins.getEnv "NIXOS_EXTRA_MODULE_PATH";
|
||||||
in if e == "" then [] else [(import (builtins.toPath e))];
|
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 {
|
in rec {
|
||||||
|
|
||||||
# Merge the option definitions in all modules, forming the full
|
# Merge the option definitions in all modules, forming the full
|
||||||
# system configuration.
|
# system configuration.
|
||||||
inherit (pkgs.lib.evalModules {
|
inherit (lib.evalModules {
|
||||||
inherit prefix;
|
inherit prefix;
|
||||||
modules = modules ++ extraModules ++ baseModules;
|
modules = modules ++ extraModules ++ baseModules ++ [ pkgsModule ];
|
||||||
args = extraArgs;
|
args = extraArgs;
|
||||||
check = check && options.environment.checkConfigurationOptions.value;
|
check = check && options.environment.checkConfigurationOptions.value;
|
||||||
}) config options;
|
}) config options;
|
||||||
@ -39,30 +51,13 @@ in rec {
|
|||||||
utils = import ./utils.nix pkgs;
|
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 =
|
pkgs =
|
||||||
if pkgs_ != null
|
if pkgs_ != null
|
||||||
then pkgs_
|
then pkgs_
|
||||||
else import ./nixpkgs.nix (
|
else import ./nixpkgs.nix (
|
||||||
let
|
let
|
||||||
system = if nixpkgsOptions.system != "" then nixpkgsOptions.system else system_;
|
system = if nixpkgsOptions.system != "" then nixpkgsOptions.system else system_;
|
||||||
nixpkgsOptions = (import ./eval-config.nix {
|
nixpkgsOptions = config.nixpkgs;
|
||||||
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;
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
inherit system;
|
inherit system;
|
||||||
|
@ -69,8 +69,4 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
|
||||||
nixpkgs.system = mkDefault pkgs.stdenv.system;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{ config, lib, pkgs, utils, ... }:
|
{ config, lib, pkgs, utils, ... }:
|
||||||
|
|
||||||
with lib;
|
|
||||||
with utils;
|
with utils;
|
||||||
|
with lib;
|
||||||
with import ./systemd-unit-options.nix { inherit config lib; };
|
with import ./systemd-unit-options.nix { inherit config lib; };
|
||||||
|
|
||||||
let
|
let
|
||||||
|
Loading…
Reference in New Issue
Block a user