feat(jsonschema): filter out $exportedModuleInfo by default
This commit is contained in:
@@ -7,6 +7,8 @@
|
|||||||
"package"
|
"package"
|
||||||
],
|
],
|
||||||
includeDefaults ? true,
|
includeDefaults ? true,
|
||||||
|
filterSchema ?
|
||||||
|
schema: lib.filterAttrsRecursive (name: _value: name != "$exportedModuleInfo") schema,
|
||||||
header ? {
|
header ? {
|
||||||
"$schema" = "http://json-schema.org/draft-07/schema#";
|
"$schema" = "http://json-schema.org/draft-07/schema#";
|
||||||
},
|
},
|
||||||
@@ -59,7 +61,7 @@ rec {
|
|||||||
inherit specialArgs;
|
inherit specialArgs;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
parseOptions evaled.options { };
|
(_parseOptions evaled.options { });
|
||||||
|
|
||||||
# get default value from option
|
# get default value from option
|
||||||
|
|
||||||
@@ -88,11 +90,13 @@ rec {
|
|||||||
let
|
let
|
||||||
subOptions = option.type.getSubOptions option.loc;
|
subOptions = option.type.getSubOptions option.loc;
|
||||||
in
|
in
|
||||||
parseOptions subOptions {
|
_parseOptions subOptions {
|
||||||
addHeader = false;
|
addHeader = false;
|
||||||
path = option.loc ++ prefix;
|
path = option.loc ++ prefix;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
parseOptions = opts: args: filterSchema (_parseOptions opts args);
|
||||||
|
|
||||||
makeModuleInfo =
|
makeModuleInfo =
|
||||||
{
|
{
|
||||||
path,
|
path,
|
||||||
@@ -115,7 +119,7 @@ rec {
|
|||||||
};
|
};
|
||||||
|
|
||||||
# parses a set of evaluated nixos options to a jsonschema
|
# parses a set of evaluated nixos options to a jsonschema
|
||||||
parseOptions =
|
_parseOptions =
|
||||||
options:
|
options:
|
||||||
{
|
{
|
||||||
# The top-level header object should specify at least the schema version
|
# The top-level header object should specify at least the schema version
|
||||||
@@ -146,7 +150,7 @@ rec {
|
|||||||
checkFreeformDefs =
|
checkFreeformDefs =
|
||||||
defs:
|
defs:
|
||||||
if (builtins.length defs) != 1 then
|
if (builtins.length defs) != 1 then
|
||||||
throw "parseOptions: freeformType definitions not supported"
|
throw "_parseOptions: freeformType definitions not supported"
|
||||||
else
|
else
|
||||||
defs;
|
defs;
|
||||||
# It seems that freeformType has [ null ]
|
# It seems that freeformType has [ null ]
|
||||||
@@ -222,7 +226,7 @@ rec {
|
|||||||
# handle nested options (not a submodule)
|
# handle nested options (not a submodule)
|
||||||
# foo.bar = mkOption { type = str; };
|
# foo.bar = mkOption { type = str; };
|
||||||
else if !option ? _type then
|
else if !option ? _type then
|
||||||
(parseOptions option {
|
(_parseOptions option {
|
||||||
addHeader = false;
|
addHeader = false;
|
||||||
path = currentPath;
|
path = currentPath;
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user