mirror of
https://github.com/nix-community/disko.git
synced 2026-11-30 13:03:28 +01:00
allow subtype definitions to be broken up
This commit is contained in:
1 parent
d5ad4485e6
commit
3db2f04765
1 file changed
+31
-12
+31
-12
@@ -23,21 +23,40 @@ let
|
||||
lib.mkOptionType {
|
||||
name = "subType";
|
||||
description = "one of ${lib.concatStringsSep "," (lib.attrNames types)}";
|
||||
check =
|
||||
x:
|
||||
if x ? type then
|
||||
types.${x.type}.check x
|
||||
else
|
||||
throw "No type option set in:\n${lib.generators.toPretty { } x}";
|
||||
check = x: lib.isAttrs x;
|
||||
merge =
|
||||
loc:
|
||||
lib.foldl' (
|
||||
_res: def:
|
||||
types.${def.value.type}.merge loc [
|
||||
loc: defs:
|
||||
let
|
||||
evaled = lib.evalModules {
|
||||
modules =
|
||||
[
|
||||
{
|
||||
freeformType = lib.types.lazyAttrsOf lib.types.raw;
|
||||
options.type = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
};
|
||||
}
|
||||
]
|
||||
++ map (
|
||||
{ value, file }:
|
||||
{
|
||||
_file = file;
|
||||
config = value;
|
||||
}
|
||||
) defs;
|
||||
};
|
||||
inherit (evaled.config) type;
|
||||
in
|
||||
types.${type}.merge loc (
|
||||
[
|
||||
# we add a dummy root parent node to render documentation
|
||||
(lib.recursiveUpdate { value._module.args = extraArgs; } def)
|
||||
{
|
||||
file = "";
|
||||
value._module.args = extraArgs;
|
||||
}
|
||||
]
|
||||
) { };
|
||||
++ defs
|
||||
);
|
||||
nestedTypes = types;
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user