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