From 7007b7d62e2258c73a3ebe908deeb35003f93826 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Sun, 27 Apr 2025 13:10:42 +0200 Subject: [PATCH 1/2] refactor: rename clanLib.values to introspection --- lib/build-clan/module.nix | 2 +- lib/default.nix | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/build-clan/module.nix b/lib/build-clan/module.nix index d8924868f..a6a40fde0 100644 --- a/lib/build-clan/module.nix +++ b/lib/build-clan/module.nix @@ -209,7 +209,7 @@ in inherit inventoryFile; inventoryValuesPrios = # Temporary workaround - builtins.removeAttrs (clan-core.clanLib.values.getPrios { options = inventory.options; }) + builtins.removeAttrs (clan-core.clanLib.introspection.getPrios { options = inventory.options; }) # tags are freeformType which is not supported yet. [ "tags" ]; diff --git a/lib/default.nix b/lib/default.nix index 02e35c4c4..cfa151cac 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -28,8 +28,11 @@ lib.fix (clanLib: { test = clanLib.callLib ./test { }; # Plain imports. - values = import ./introspection { inherit lib; }; + introspection = import ./introspection { inherit lib; }; jsonschema = import ./jsonschema { inherit lib; }; - inherit (self.inputs.nix-select.lib) parseSelector applySelectors select; facts = import ./facts.nix { inherit lib; }; + + # Passthrough from self.inputs + # TODO: Can we make these agnostic from the name of the input? + inherit (self.inputs.nix-select.lib) parseSelector applySelectors select; }) From b87d5a238c3b0e6c0e5f6e508cf94beb017a8a61 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Sun, 27 Apr 2025 13:14:09 +0200 Subject: [PATCH 2/2] chore: remove unused moduleSchemas and related API endpoint for legacy modules We didn't reach the state where we would display these schemas in the UI. We might need to wire this up in a similar way for the newer clan.services --- lib/build-clan/interface.nix | 1 - lib/build-clan/module.nix | 6 ------ pkgs/clan-cli/clan_lib/api/modules.py | 22 ---------------------- 3 files changed, 29 deletions(-) diff --git a/lib/build-clan/interface.nix b/lib/build-clan/interface.nix index bcab2a621..405be0470 100644 --- a/lib/build-clan/interface.nix +++ b/lib/build-clan/interface.nix @@ -158,7 +158,6 @@ in # all exported clan modules from this clan modules = lib.mkOption { type = lib.types.raw; }; # all inventory module schemas - moduleSchemas = lib.mkOption { type = lib.types.raw; }; inventoryFile = lib.mkOption { type = lib.types.raw; }; # The machine 'imports' generated by the inventory per machine inventoryClass = lib.mkOption { type = lib.types.raw; }; diff --git a/lib/build-clan/module.nix b/lib/build-clan/module.nix index a6a40fde0..a72c00c41 100644 --- a/lib/build-clan/module.nix +++ b/lib/build-clan/module.nix @@ -193,12 +193,6 @@ in name: _: inventory.machines.${name}.machineClass or "nixos" == "darwin" ) (config.outputs.moduleForMachine); - moduleSchemas = clan-core.clanLib.modules.getModulesSchema { - modules = config.inventory.modules; - # TODO: make this function system agnostic - pkgs = nixpkgs.legacyPackages."x86_64-linux"; - inherit clan-core; - }; inherit inventoryClass; # TODO: unify this interface diff --git a/pkgs/clan-cli/clan_lib/api/modules.py b/pkgs/clan-cli/clan_lib/api/modules.py index d1205a3e5..3125cbb86 100644 --- a/pkgs/clan-cli/clan_lib/api/modules.py +++ b/pkgs/clan-cli/clan_lib/api/modules.py @@ -174,28 +174,6 @@ def get_modules(base_path: str) -> dict[str, str]: return modules -@API.register -def get_module_interface(base_path: str, module_name: str) -> dict[str, Any]: - """ - Check if a module exists and returns the interface schema - Returns an error if the module does not exist or has an incorrect interface - """ - cmd = nix_eval([f"{base_path}#clanInternals.moduleSchemas.{module_name}", "--json"]) - try: - proc = run_no_stdout(cmd) - res = proc.stdout.strip() - except ClanCmdError as e: - msg = "clanInternals might not have moduleSchemas attributes" - raise ClanError( - msg, - location=f"list_modules {base_path}", - description="Evaluation failed on clanInternals.moduleSchemas attribute", - ) from e - modules_schema: dict[str, Any] = json.loads(res) - - return modules_schema - - @API.register def list_modules(base_path: str) -> dict[str, ModuleInfo]: """