nixos/eval-config: Avoid evalModules args and check parameters

This commit is contained in:
Robert Hensing 2021-12-02 18:07:39 +00:00
parent b37f099ae7
commit 59c4a35aab

View file

@ -8,6 +8,7 @@
# as subcomponents (e.g. the container feature, or nixops if network # as subcomponents (e.g. the container feature, or nixops if network
# expressions are ever made modular at the top level) can just use # expressions are ever made modular at the top level) can just use
# types.submodule instead of using eval-config.nix # types.submodule instead of using eval-config.nix
evalConfigArgs@
{ # !!! system can be set modularly, would be nice to remove { # !!! system can be set modularly, would be nice to remove
system ? builtins.currentSystem system ? builtins.currentSystem
, # !!! is this argument needed any more? The pkgs argument can , # !!! is this argument needed any more? The pkgs argument can
@ -28,7 +29,7 @@
in if e == "" then [] else [(import e)] in if e == "" then [] else [(import e)]
}: }:
let extraArgs_ = extraArgs; pkgs_ = pkgs; let pkgs_ = pkgs;
in in
let let
@ -51,25 +52,40 @@ let
}; };
}; };
noUserModules = lib.evalModules { legacyModules =
inherit prefix check; lib.optional (evalConfigArgs?args) {
modules = baseModules ++ extraModules ++ [ pkgsModule ]; config = {
args = extraArgs; _module.args = extraArgs;
};
}
++ lib.optional (evalConfigArgs?check) {
config = {
_module.check = lib.mkDefault check;
};
};
allUserModules = modules ++ legacyModules;
noUserModules = lib.evalModules ({
inherit prefix;
modules = baseModules ++ extraModules ++ [ pkgsModule modulesModule ];
specialArgs = specialArgs =
{ modulesPath = builtins.toString ../modules; } // specialArgs; { modulesPath = builtins.toString ../modules; } // specialArgs;
}; });
# These are the extra arguments passed to every module. In # Extra arguments that are useful for constructing a similar configuration.
# particular, Nixpkgs is passed through the "pkgs" argument. modulesModule = {
extraArgs = extraArgs_ // { config = {
inherit noUserModules baseModules extraModules modules; _module.args = {
inherit noUserModules baseModules extraModules modules;
};
};
}; };
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 (noUserModules.extendModules { inherit modules; }) inherit (noUserModules.extendModules { modules = allUserModules; })
config options _module type; config options _module type;
inherit extraArgs; inherit extraArgs;