summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSilvan Mosberger <contact@infinisil.com>2021-12-07 18:30:52 +0100
committerGitHub <noreply@github.com>2021-12-07 18:30:52 +0100
commit490d46f044d3c82b4948626fa2fca5be7903434e (patch)
treec0593855dcf951de15fcdcd0bb861e446db53997 /lib
parentbb8900960cb01bd15c472bbf25ee34a4b0c0c7c2 (diff)
parent260b941dd0e7e72cf9b87f36f92b7e60f38d661f (diff)
Merge pull request #148315 from hercules-ci/nixos-evalModules-legacy-cleanup
NixOS/evalModules legacy cleanup
Diffstat (limited to 'lib')
-rw-r--r--lib/modules.nix32
1 files changed, 27 insertions, 5 deletions
diff --git a/lib/modules.nix b/lib/modules.nix
index 2468b6fbdd22..ee1aa16dbb04 100644
--- a/lib/modules.nix
+++ b/lib/modules.nix
@@ -101,9 +101,31 @@ rec {
check ? true
}:
let
+ withWarnings = x:
+ lib.warnIf (evalModulesArgs?args) "The args argument to evalModules is deprecated. Please set config._module.args instead."
+ lib.warnIf (evalModulesArgs?check) "The check argument to evalModules is deprecated. Please set config._module.check instead."
+ x;
+
+ legacyModules =
+ optional (evalModulesArgs?args) {
+ config = {
+ _module.args = args;
+ };
+ }
+ ++ optional (evalModulesArgs?check) {
+ config = {
+ _module.check = mkDefault check;
+ };
+ };
+ regularModules = modules ++ legacyModules;
+
# This internal module declare internal options under the `_module'
# attribute. These options are fragile, as they are used by the
# module system to change the interpretation of modules.
+ #
+ # When extended with extendModules or moduleType, a fresh instance of
+ # this module is used, to avoid conflicts and allow chaining of
+ # extendModules.
internalModule = rec {
_file = ./modules.nix;
@@ -125,7 +147,7 @@ rec {
_module.check = mkOption {
type = types.bool;
internal = true;
- default = check;
+ default = true;
description = "Whether to check whether all option definitions have matching declarations.";
};
@@ -151,14 +173,14 @@ rec {
_module.args = {
inherit extendModules;
moduleType = type;
- } // args;
+ };
};
};
merged =
let collected = collectModules
(specialArgs.modulesPath or "")
- (modules ++ [ internalModule ])
+ (regularModules ++ [ internalModule ])
({ inherit lib options config specialArgs; } // specialArgs);
in mergeModules prefix (reverseList collected);
@@ -222,7 +244,7 @@ rec {
prefix ? [],
}:
evalModules (evalModulesArgs // {
- modules = evalModulesArgs.modules ++ modules;
+ modules = regularModules ++ modules;
specialArgs = evalModulesArgs.specialArgs or {} // specialArgs;
prefix = extendArgs.prefix or evalModulesArgs.prefix;
});
@@ -231,7 +253,7 @@ rec {
inherit modules specialArgs;
};
- result = {
+ result = withWarnings {
options = checked options;
config = checked (removeAttrs config [ "_module" ]);
_module = checked (config._module);