lib/types: Allow paths as submodule values
This commit is contained in:
parent
bc42515736
commit
eec83d41e3
@ -376,14 +376,16 @@ rec {
|
|||||||
else unify (if shorthandOnlyDefinesConfig then { config = value; } else value);
|
else unify (if shorthandOnlyDefinesConfig then { config = value; } else value);
|
||||||
|
|
||||||
allModules = defs: modules ++ imap1 (n: { value, file }:
|
allModules = defs: modules ++ imap1 (n: { value, file }:
|
||||||
# Annotate the value with the location of its definition for better error messages
|
if isAttrs value || isFunction value then
|
||||||
coerce (lib.modules.unifyModuleSyntax file "${toString file}-${toString n}") value
|
# Annotate the value with the location of its definition for better error messages
|
||||||
|
coerce (lib.modules.unifyModuleSyntax file "${toString file}-${toString n}") value
|
||||||
|
else value
|
||||||
) defs;
|
) defs;
|
||||||
|
|
||||||
in
|
in
|
||||||
mkOptionType rec {
|
mkOptionType rec {
|
||||||
name = "submodule";
|
name = "submodule";
|
||||||
check = x: isAttrs x || isFunction x;
|
check = x: isAttrs x || isFunction x || path.check x;
|
||||||
merge = loc: defs:
|
merge = loc: defs:
|
||||||
(evalModules {
|
(evalModules {
|
||||||
modules = allModules defs;
|
modules = allModules defs;
|
||||||
|
@ -257,9 +257,9 @@
|
|||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
A set of sub options <replaceable>o</replaceable>.
|
A set of sub options <replaceable>o</replaceable>.
|
||||||
<replaceable>o</replaceable> can be an attribute set or a function
|
<replaceable>o</replaceable> can be an attribute set, a function
|
||||||
returning an attribute set. Submodules are used in composed types to
|
returning an attribute set, or a path to a file containing such a value. Submodules are used in
|
||||||
create modular options. This is equivalent to
|
composed types to create modular options. This is equivalent to
|
||||||
<literal>types.submoduleWith { modules = toList o; shorthandOnlyDefinesConfig = true; }</literal>.
|
<literal>types.submoduleWith { modules = toList o; shorthandOnlyDefinesConfig = true; }</literal>.
|
||||||
Submodules are detailed in
|
Submodules are detailed in
|
||||||
<xref
|
<xref
|
||||||
|
Loading…
Reference in New Issue
Block a user