modules: Add extendModules to module args

This commit is contained in:
Robert Hensing 2021-10-29 13:15:38 +02:00
parent dece37b83a
commit 27644a82a9

View File

@ -121,7 +121,9 @@ rec {
}; };
config = { config = {
_module.args = args; _module.args = {
inherit extendModules;
} // args;
}; };
}; };
@ -186,24 +188,26 @@ rec {
checked = builtins.seq checkUnmatched; checked = builtins.seq checkUnmatched;
extendModules = extendArgs@{
modules ? [],
specialArgs ? {},
prefix ? [],
}:
evalModules (evalModulesArgs // {
modules = evalModulesArgs.modules ++ modules;
specialArgs = evalModulesArgs.specialArgs or {} // specialArgs;
prefix = extendArgs.prefix or evalModulesArgs.prefix;
});
type = lib.types.submoduleWith {
inherit modules specialArgs;
};
result = { result = {
options = checked options; options = checked options;
config = checked (removeAttrs config [ "_module" ]); config = checked (removeAttrs config [ "_module" ]);
_module = checked (config._module); _module = checked (config._module);
inherit extendModules type;
extendModules = extendArgs@{
modules ? [],
specialArgs ? {},
prefix ? [],
}:
evalModules (evalModulesArgs // {
modules = evalModulesArgs.modules ++ modules;
specialArgs = evalModulesArgs.specialArgs or {} // specialArgs;
prefix = extendArgs.prefix or evalModulesArgs.prefix;
});
type = lib.types.submoduleWith {
inherit modules specialArgs;
};
}; };
in result; in result;