fix(inventory/instances): fix jsonschema compatibility

This commit is contained in:
Johannes Kirschbauer
2025-03-27 19:35:59 +01:00
parent 8a0e4b4ac4
commit ca1777fddc
4 changed files with 14 additions and 24 deletions

View File

@@ -15,24 +15,6 @@ in
... ...
}: }:
{ {
devShells.inventory-schema = pkgs.mkShell {
inputsFrom = with config.checks; [
lib-inventory-eval
self'.devShells.default
];
};
legacyPackages.schemas = (
import ./schemas {
inherit
pkgs
self
lib
self'
;
}
);
# Run: nix-unit --extra-experimental-features flakes --flake .#legacyPackages.x86_64-linux.<attrName> # Run: nix-unit --extra-experimental-features flakes --flake .#legacyPackages.x86_64-linux.<attrName>
legacyPackages.evalTest-distributedServices = import ./tests { legacyPackages.evalTest-distributedServices = import ./tests {
inherit lib self; inherit lib self;
@@ -45,7 +27,7 @@ in
nix-unit --eval-store "$HOME" \ nix-unit --eval-store "$HOME" \
--extra-experimental-features flakes \ --extra-experimental-features flakes \
${inputOverrides} \ ${inputOverrides} \
--flake ${self}#legacyPackages.${system}.distributedServices --flake ${self}#legacyPackages.${system}.evalTest-distributedServices
touch $out touch $out
''; '';

View File

@@ -204,8 +204,9 @@ in
elemType = submoduleWith { elemType = submoduleWith {
modules = [ modules = [
(m: { (m: {
# TODO: make this a deferred module? # TODO: Move the deferred module type into inventory interface ?
options.settings = mkOption { options.settings = mkOption {
type = types.deferredModule;
description = "Settings of '${name}-machine': ${m.name}."; description = "Settings of '${name}-machine': ${m.name}.";
default = { }; default = { };
}; };
@@ -220,6 +221,7 @@ in
# options._settingsViaTags = mkOption { }; # options._settingsViaTags = mkOption { };
# A deferred module that combines _settingsViaTags with _settings # A deferred module that combines _settingsViaTags with _settings
options.settings = mkOption { options.settings = mkOption {
type = types.deferredModule;
description = "Settings of 'role': ${name}"; description = "Settings of 'role': ${name}";
default = { }; default = { };
}; };

View File

@@ -103,7 +103,9 @@ in
default = options; default = options;
}; };
modules = lib.mkOption { modules = lib.mkOption {
type = types.attrsOf (types.either types.path types.deferredModule); # Don't define the type yet
# We manually transform the value with types.deferredModule.merge later to keep them serializable
type = types.attrsOf types.raw;
default = { }; default = { };
defaultText = "clanModules of clan-core"; defaultText = "clanModules of clan-core";
description = '' description = ''
@@ -310,7 +312,9 @@ in
types.submodule { types.submodule {
options.settings = lib.mkOption { options.settings = lib.mkOption {
default = { }; default = { };
type = types.deferredModule; # Dont transform the value with `types.deferredModule` here. We need to keep it json serializable
# TODO: We need a custom serializer for deferredModule
type = types.attrsOf types.raw;
}; };
} }
); );
@@ -321,7 +325,7 @@ in
types.submodule { types.submodule {
options.settings = lib.mkOption { options.settings = lib.mkOption {
default = { }; default = { };
type = types.deferredModule; type = types.attrsOf types.raw;
}; };
} }
); );
@@ -329,7 +333,7 @@ in
}; };
settings = lib.mkOption { settings = lib.mkOption {
default = { }; default = { };
type = types.deferredModule; type = types.attrsOf types.raw;
}; };
}; };
} }

View File

@@ -32,6 +32,8 @@ def map_json_type(
return {"str"} return {"str"}
if json_type == "integer": if json_type == "integer":
return {"int"} return {"int"}
if json_type == "number":
return {"float"}
if json_type == "boolean": if json_type == "boolean":
return {"bool"} return {"bool"}
# In Python, "number" is analogous to the float type. # In Python, "number" is analogous to the float type.