From 80bc3daf96421176e51db0f1767e0a2bec1bffe0 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Tue, 16 Sep 2025 17:11:19 +0200 Subject: [PATCH] lib/jsonschema: remove unused arguments --- lib/jsonschema/default.nix | 7 ++----- lib/jsonschema/test_parseOptions.nix | 10 +++------- .../inventory/distributed-service/api-feature.nix | 1 - lib/modules/inventory/schemas/default.nix | 3 +-- 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/lib/jsonschema/default.nix b/lib/jsonschema/default.nix index 2b4aab9a3..a0c983303 100644 --- a/lib/jsonschema/default.nix +++ b/lib/jsonschema/default.nix @@ -6,7 +6,6 @@ "functionTo" "package" ], - includeDefaults ? true, filterSchema ? schema: lib.filterAttrsRecursive (name: _value: name != "$exportedModuleInfo") schema, header ? { @@ -61,7 +60,7 @@ rec { inherit specialArgs; }; in - (_parseOptions evaled.options { }); + filterSchema (_parseOptions evaled.options { }); # get default value from option @@ -70,9 +69,7 @@ rec { # - Value is "" (string literal) if the option has a defaultText attribute. This means we cannot evaluate default safely getDefaultFrom = opt: - if !includeDefaults then - { } - else if opt ? defaultText then + if opt ? defaultText then { # dont add default to jsonschema. It seems to alter the type # default = ""; diff --git a/lib/jsonschema/test_parseOptions.nix b/lib/jsonschema/test_parseOptions.nix index 739f2f058..c9f3fc19f 100644 --- a/lib/jsonschema/test_parseOptions.nix +++ b/lib/jsonschema/test_parseOptions.nix @@ -4,13 +4,9 @@ lib ? (import { }).lib, slib ? (import ./. { inherit lib; } { }), }: -let - filterSchema = - schema: lib.filterAttrsRecursive (name: _value: name != "$exportedModuleInfo") schema; -in { testParseOptions = { - expr = filterSchema (slib.parseModule ./example-interface.nix); + expr = (slib.parseModule ./example-interface.nix); expected = builtins.fromJSON (builtins.readFile ./example-schema.json); }; @@ -31,7 +27,7 @@ in }; in { - expr = filterSchema (slib.parseOptions evaled.options { }); + expr = (slib.parseOptions evaled.options { }); expected = { "$schema" = "http://json-schema.org/draft-07/schema#"; additionalProperties = false; @@ -64,7 +60,7 @@ in }; in { - expr = filterSchema ( + expr = ( slib.parseOptions (lib.evalModules { modules = [ diff --git a/lib/modules/inventory/distributed-service/api-feature.nix b/lib/modules/inventory/distributed-service/api-feature.nix index e5d4a8113..180877800 100644 --- a/lib/modules/inventory/distributed-service/api-feature.nix +++ b/lib/modules/inventory/distributed-service/api-feature.nix @@ -4,7 +4,6 @@ { clanLib, prefix }: let converter = clanLib.jsonschema { - includeDefaults = true; }; in { lib, config, ... }: diff --git a/lib/modules/inventory/schemas/default.nix b/lib/modules/inventory/schemas/default.nix index f85096db5..375a9bdb1 100644 --- a/lib/modules/inventory/schemas/default.nix +++ b/lib/modules/inventory/schemas/default.nix @@ -6,8 +6,7 @@ ... }: let - jsonLib = self.clanLib.jsonschema { inherit includeDefaults; }; - includeDefaults = true; + jsonLib = self.clanLib.jsonschema { }; opts = (flakeOptions.flake.type.getSubOptions [ "flake" ]); clanOpts = opts.clan.type.getSubOptions [ "clan" ];