diff options
author | Robert Hensing <robert@roberthensing.nl> | 2021-12-02 17:45:48 +0000 |
---|---|---|
committer | Robert Hensing <robert@roberthensing.nl> | 2021-12-02 17:45:48 +0000 |
commit | b37f099ae7fa01e263530754b8e23bcc8730f221 (patch) | |
tree | fc7c56c3f5231dc8162d6aebc06c3d88a84d5cfc /lib/modules.nix | |
parent | fa06cf556e84ed7991ba78d92a4093a8dc0d5056 (diff) | |
download | nixpkgs-b37f099ae7fa01e263530754b8e23bcc8730f221.tar nixpkgs-b37f099ae7fa01e263530754b8e23bcc8730f221.tar.gz nixpkgs-b37f099ae7fa01e263530754b8e23bcc8730f221.tar.bz2 nixpkgs-b37f099ae7fa01e263530754b8e23bcc8730f221.tar.lz nixpkgs-b37f099ae7fa01e263530754b8e23bcc8730f221.tar.xz nixpkgs-b37f099ae7fa01e263530754b8e23bcc8730f221.tar.zst nixpkgs-b37f099ae7fa01e263530754b8e23bcc8730f221.zip |
lib/modules: Pass legacy args argument along through extendModules
Diffstat (limited to 'lib/modules.nix')
-rw-r--r-- | lib/modules.nix | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/lib/modules.nix b/lib/modules.nix index 2468b6fbdd2..b9f1b635975 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -101,9 +101,26 @@ rec { check ? true }: let + 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 +142,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 +168,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 +239,7 @@ rec { prefix ? [], }: evalModules (evalModulesArgs // { - modules = evalModulesArgs.modules ++ modules; + modules = regularModules ++ modules; specialArgs = evalModulesArgs.specialArgs or {} // specialArgs; prefix = extendArgs.prefix or evalModulesArgs.prefix; }); |