lan-config: handle nested options #122

Merged
clan-bot merged 1 commits from DavHau-clan-config into main 2023-08-09 16:20:40 +00:00
2 changed files with 33 additions and 1 deletions

View File

@ -56,7 +56,13 @@ rec {
inherit (option) description;
};
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"
# parse nullOr

View File

@ -17,4 +17,30 @@ in
expr = slib.parseOptions evaledOptions;
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";
};
};
}