Merge pull request 'lan-config: handle nested options' (#122) from DavHau-clan-config into main
This commit is contained in:
@@ -56,7 +56,13 @@ rec {
|
|||||||
inherit (option) description;
|
inherit (option) description;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
if option._type != "option"
|
|
||||||
|
# handle nested options (not a submodule)
|
||||||
|
if ! option ? _type
|
||||||
|
then parseOptions option
|
||||||
|
|
||||||
|
# throw if not an option
|
||||||
|
else if option._type != "option"
|
||||||
then throw "parseOption: not an option"
|
then throw "parseOption: not an option"
|
||||||
|
|
||||||
# parse nullOr
|
# parse nullOr
|
||||||
|
|||||||
@@ -17,4 +17,30 @@ in
|
|||||||
expr = slib.parseOptions evaledOptions;
|
expr = slib.parseOptions evaledOptions;
|
||||||
expected = builtins.fromJSON (builtins.readFile ./example-schema.json);
|
expected = builtins.fromJSON (builtins.readFile ./example-schema.json);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
testParseNestedOptions =
|
||||||
|
let
|
||||||
|
evaled = lib.evalModules {
|
||||||
|
modules = [{
|
||||||
|
options.foo.bar = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
};
|
||||||
|
}];
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
expr = slib.parseOptions evaled.options;
|
||||||
|
expected = {
|
||||||
|
properties = {
|
||||||
|
foo = {
|
||||||
|
properties = {
|
||||||
|
bar = { type = "boolean"; };
|
||||||
|
};
|
||||||
|
required = [ "bar" ];
|
||||||
|
type = "object";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
type = "object";
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user