forked from clan/clan-core
jsonschema: Filter out 'invisible' options, that are there to throw errors on define
This commit is contained in:
parent
159198b81a
commit
393ed517e2
@ -17,7 +17,7 @@ let
|
|||||||
location: ${lib.concatStringsSep "." option.loc}
|
location: ${lib.concatStringsSep "." option.loc}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# Exclude the option if it's type is in the excludedTypes list
|
# Exclude the option if its type is in the excludedTypes list
|
||||||
# or if the option has a defaultText attribute
|
# or if the option has a defaultText attribute
|
||||||
isExcludedOption =
|
isExcludedOption =
|
||||||
option: ((lib.elem (option.type.name or null) excludedTypes) || (option ? defaultText));
|
option: ((lib.elem (option.type.name or null) excludedTypes) || (option ? defaultText));
|
||||||
@ -26,6 +26,9 @@ let
|
|||||||
|
|
||||||
filterExcludedAttrs = lib.filterAttrs (_name: opt: !isExcludedOption opt);
|
filterExcludedAttrs = lib.filterAttrs (_name: opt: !isExcludedOption opt);
|
||||||
|
|
||||||
|
# Filter out options where the visible attribute is set to false
|
||||||
|
filterInvisibleOpts = lib.filterAttrs (_name: opt: opt.visible or true);
|
||||||
|
|
||||||
allBasicTypes = [
|
allBasicTypes = [
|
||||||
"boolean"
|
"boolean"
|
||||||
"integer"
|
"integer"
|
||||||
@ -50,7 +53,7 @@ rec {
|
|||||||
parseOptions =
|
parseOptions =
|
||||||
options':
|
options':
|
||||||
let
|
let
|
||||||
options = filterExcludedAttrs (clean options');
|
options = filterInvisibleOpts (filterExcludedAttrs (clean options'));
|
||||||
# parse options to jsonschema properties
|
# parse options to jsonschema properties
|
||||||
properties = lib.mapAttrs (_name: option: parseOption option) options;
|
properties = lib.mapAttrs (_name: option: parseOption option) options;
|
||||||
# TODO: figure out how to handle if prop.anyOf is used
|
# TODO: figure out how to handle if prop.anyOf is used
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
# Uncomment if you only want one module to be available
|
# Uncomment if you only want one module to be available
|
||||||
# clanModules = {
|
# clanModules = {
|
||||||
# syncthing = self.clanModules.syncthing;
|
# borgbackup = self.clanModules.borgbackup;
|
||||||
# };
|
# };
|
||||||
|
|
||||||
baseModule = {
|
baseModule = {
|
||||||
@ -30,6 +30,7 @@
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
# Filter out "injected" options that are not part of the module
|
||||||
if (evaled.options.clan ? "${modulename}") then evaled.options.clan.${modulename} else { };
|
if (evaled.options.clan ? "${modulename}") then evaled.options.clan.${modulename} else { };
|
||||||
|
|
||||||
clanModuleSchemas = lib.mapAttrs (
|
clanModuleSchemas = lib.mapAttrs (
|
||||||
|
Loading…
Reference in New Issue
Block a user