From 1019911b204d47881e76a2431b55feae80528229 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Wed, 4 Jun 2025 20:22:54 +0200 Subject: [PATCH] feat(jsonschema): filter out $exportedModuleInfo by default --- lib/jsonschema/default.nix | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/jsonschema/default.nix b/lib/jsonschema/default.nix index 73b511f8f..7ec0ff76e 100644 --- a/lib/jsonschema/default.nix +++ b/lib/jsonschema/default.nix @@ -7,6 +7,8 @@ "package" ], includeDefaults ? true, + filterSchema ? + schema: lib.filterAttrsRecursive (name: _value: name != "$exportedModuleInfo") schema, header ? { "$schema" = "http://json-schema.org/draft-07/schema#"; }, @@ -59,7 +61,7 @@ rec { inherit specialArgs; }; in - parseOptions evaled.options { }; + (_parseOptions evaled.options { }); # get default value from option @@ -88,11 +90,13 @@ rec { let subOptions = option.type.getSubOptions option.loc; in - parseOptions subOptions { + _parseOptions subOptions { addHeader = false; path = option.loc ++ prefix; }; + parseOptions = opts: args: filterSchema (_parseOptions opts args); + makeModuleInfo = { path, @@ -115,7 +119,7 @@ rec { }; # parses a set of evaluated nixos options to a jsonschema - parseOptions = + _parseOptions = options: { # The top-level header object should specify at least the schema version @@ -146,7 +150,7 @@ rec { checkFreeformDefs = defs: if (builtins.length defs) != 1 then - throw "parseOptions: freeformType definitions not supported" + throw "_parseOptions: freeformType definitions not supported" else defs; # It seems that freeformType has [ null ] @@ -222,7 +226,7 @@ rec { # handle nested options (not a submodule) # foo.bar = mkOption { type = str; }; else if !option ? _type then - (parseOptions option { + (_parseOptions option { addHeader = false; path = currentPath; })