lib.types: Add deferredModuleWith
This commit is contained in:
parent
781c2e0789
commit
19a069ab8b
@ -467,7 +467,9 @@ rec {
|
|||||||
disabledModules = m.disabledModules or [];
|
disabledModules = m.disabledModules or [];
|
||||||
imports = m.require or [] ++ m.imports or [];
|
imports = m.require or [] ++ m.imports or [];
|
||||||
options = {};
|
options = {};
|
||||||
config = addFreeformType (addMeta (removeAttrs m ["_file" "key" "disabledModules" "require" "imports" "freeformType"]));
|
config =
|
||||||
|
lib.throwIfNot (isAttrs m) "module ${file} (${key}) does not look like a module."
|
||||||
|
addFreeformType (addMeta (removeAttrs m ["_file" "key" "disabledModules" "require" "imports" "freeformType"]));
|
||||||
};
|
};
|
||||||
|
|
||||||
applyModuleArgsIfFunction = key: f: args@{ config, options, lib, ... }: if isFunction f then
|
applyModuleArgsIfFunction = key: f: args@{ config, options, lib, ... }: if isFunction f then
|
||||||
|
@ -540,11 +540,31 @@ rec {
|
|||||||
};
|
};
|
||||||
|
|
||||||
# A module to be imported in some other part of the configuration.
|
# A module to be imported in some other part of the configuration.
|
||||||
deferredModule = mkOptionType {
|
deferredModule = deferredModuleWith { };
|
||||||
|
|
||||||
|
# A module to be imported in some other part of the configuration.
|
||||||
|
# `staticModules`' options will be added to the documentation, unlike
|
||||||
|
# options declared via `config`.
|
||||||
|
deferredModuleWith = attrs@{ staticModules ? [] }: mkOptionType {
|
||||||
name = "deferredModule";
|
name = "deferredModule";
|
||||||
description = "module";
|
description = "module";
|
||||||
check = x: isAttrs x || isFunction x || path.check x;
|
check = x: isAttrs x || isFunction x || path.check x;
|
||||||
merge = loc: defs: map (def: lib.setDefaultModuleLocation "${def.file}, via option ${showOption loc}" def.value) defs;
|
merge = loc: defs: staticModules ++ map (def: lib.setDefaultModuleLocation "${def.file}, via option ${showOption loc}" def.value) defs;
|
||||||
|
inherit (submoduleWith { modules = staticModules; })
|
||||||
|
getSubOptions
|
||||||
|
getSubModules;
|
||||||
|
substSubModules = m: deferredModuleWith (attrs // {
|
||||||
|
staticModules = m;
|
||||||
|
});
|
||||||
|
functor = defaultFunctor "deferredModuleWith" // {
|
||||||
|
type = types.deferredModuleWith;
|
||||||
|
payload = {
|
||||||
|
inherit staticModules;
|
||||||
|
};
|
||||||
|
binOp = lhs: rhs: {
|
||||||
|
staticModules = lhs.staticModules ++ rhs.staticModules;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# The type of a type!
|
# The type of a type!
|
||||||
|
Loading…
Reference in New Issue
Block a user