Merge pull request 'lib/jsonschema: remove unused arguments' (#5176) from lib-1 into main
Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/5176
This commit is contained in:
@@ -6,7 +6,6 @@
|
|||||||
"functionTo"
|
"functionTo"
|
||||||
"package"
|
"package"
|
||||||
],
|
],
|
||||||
includeDefaults ? true,
|
|
||||||
filterSchema ?
|
filterSchema ?
|
||||||
schema: lib.filterAttrsRecursive (name: _value: name != "$exportedModuleInfo") schema,
|
schema: lib.filterAttrsRecursive (name: _value: name != "$exportedModuleInfo") schema,
|
||||||
header ? {
|
header ? {
|
||||||
@@ -61,7 +60,7 @@ rec {
|
|||||||
inherit specialArgs;
|
inherit specialArgs;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
(_parseOptions evaled.options { });
|
filterSchema (_parseOptions evaled.options { });
|
||||||
|
|
||||||
# get default value from option
|
# get default value from option
|
||||||
|
|
||||||
@@ -70,9 +69,7 @@ rec {
|
|||||||
# - Value is "<thunk>" (string literal) if the option has a defaultText attribute. This means we cannot evaluate default safely
|
# - Value is "<thunk>" (string literal) if the option has a defaultText attribute. This means we cannot evaluate default safely
|
||||||
getDefaultFrom =
|
getDefaultFrom =
|
||||||
opt:
|
opt:
|
||||||
if !includeDefaults then
|
if opt ? defaultText then
|
||||||
{ }
|
|
||||||
else if opt ? defaultText then
|
|
||||||
{
|
{
|
||||||
# dont add default to jsonschema. It seems to alter the type
|
# dont add default to jsonschema. It seems to alter the type
|
||||||
# default = "<thunk>";
|
# default = "<thunk>";
|
||||||
|
|||||||
@@ -4,13 +4,9 @@
|
|||||||
lib ? (import <nixpkgs> { }).lib,
|
lib ? (import <nixpkgs> { }).lib,
|
||||||
slib ? (import ./. { inherit lib; } { }),
|
slib ? (import ./. { inherit lib; } { }),
|
||||||
}:
|
}:
|
||||||
let
|
|
||||||
filterSchema =
|
|
||||||
schema: lib.filterAttrsRecursive (name: _value: name != "$exportedModuleInfo") schema;
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
testParseOptions = {
|
testParseOptions = {
|
||||||
expr = filterSchema (slib.parseModule ./example-interface.nix);
|
expr = (slib.parseModule ./example-interface.nix);
|
||||||
expected = builtins.fromJSON (builtins.readFile ./example-schema.json);
|
expected = builtins.fromJSON (builtins.readFile ./example-schema.json);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -31,7 +27,7 @@ in
|
|||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
expr = filterSchema (slib.parseOptions evaled.options { });
|
expr = (slib.parseOptions evaled.options { });
|
||||||
expected = {
|
expected = {
|
||||||
"$schema" = "http://json-schema.org/draft-07/schema#";
|
"$schema" = "http://json-schema.org/draft-07/schema#";
|
||||||
additionalProperties = false;
|
additionalProperties = false;
|
||||||
@@ -64,7 +60,7 @@ in
|
|||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
expr = filterSchema (
|
expr = (
|
||||||
slib.parseOptions
|
slib.parseOptions
|
||||||
(lib.evalModules {
|
(lib.evalModules {
|
||||||
modules = [
|
modules = [
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
{ clanLib, prefix }:
|
{ clanLib, prefix }:
|
||||||
let
|
let
|
||||||
converter = clanLib.jsonschema {
|
converter = clanLib.jsonschema {
|
||||||
includeDefaults = true;
|
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{ lib, config, ... }:
|
{ lib, config, ... }:
|
||||||
|
|||||||
@@ -6,8 +6,7 @@
|
|||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
jsonLib = self.clanLib.jsonschema { inherit includeDefaults; };
|
jsonLib = self.clanLib.jsonschema { };
|
||||||
includeDefaults = true;
|
|
||||||
|
|
||||||
opts = (flakeOptions.flake.type.getSubOptions [ "flake" ]);
|
opts = (flakeOptions.flake.type.getSubOptions [ "flake" ]);
|
||||||
clanOpts = opts.clan.type.getSubOptions [ "clan" ];
|
clanOpts = opts.clan.type.getSubOptions [ "clan" ];
|
||||||
|
|||||||
Reference in New Issue
Block a user