0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-14 06:00:33 +03:00

lib/modules: Pass legacy args argument along through extendModules

This commit is contained in:
Robert Hensing 2021-12-02 17:45:48 +00:00
parent fa06cf556e
commit b37f099ae7

View file

@ -101,9 +101,26 @@ rec {
check ? true check ? true
}: }:
let 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' # This internal module declare internal options under the `_module'
# attribute. These options are fragile, as they are used by the # attribute. These options are fragile, as they are used by the
# module system to change the interpretation of modules. # 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 { internalModule = rec {
_file = ./modules.nix; _file = ./modules.nix;
@ -125,7 +142,7 @@ rec {
_module.check = mkOption { _module.check = mkOption {
type = types.bool; type = types.bool;
internal = true; internal = true;
default = check; default = true;
description = "Whether to check whether all option definitions have matching declarations."; description = "Whether to check whether all option definitions have matching declarations.";
}; };
@ -151,14 +168,14 @@ rec {
_module.args = { _module.args = {
inherit extendModules; inherit extendModules;
moduleType = type; moduleType = type;
} // args; };
}; };
}; };
merged = merged =
let collected = collectModules let collected = collectModules
(specialArgs.modulesPath or "") (specialArgs.modulesPath or "")
(modules ++ [ internalModule ]) (regularModules ++ [ internalModule ])
({ inherit lib options config specialArgs; } // specialArgs); ({ inherit lib options config specialArgs; } // specialArgs);
in mergeModules prefix (reverseList collected); in mergeModules prefix (reverseList collected);
@ -222,7 +239,7 @@ rec {
prefix ? [], prefix ? [],
}: }:
evalModules (evalModulesArgs // { evalModules (evalModulesArgs // {
modules = evalModulesArgs.modules ++ modules; modules = regularModules ++ modules;
specialArgs = evalModulesArgs.specialArgs or {} // specialArgs; specialArgs = evalModulesArgs.specialArgs or {} // specialArgs;
prefix = extendArgs.prefix or evalModulesArgs.prefix; prefix = extendArgs.prefix or evalModulesArgs.prefix;
}); });