diff --git a/lib/build-clan/interface.nix b/lib/build-clan/interface.nix index c63b81af1..7e70b90e8 100644 --- a/lib/build-clan/interface.nix +++ b/lib/build-clan/interface.nix @@ -194,7 +194,8 @@ in visible = false; # ClanInternals type = types.submodule { - freeformType = types.attrsOf types.raw; + # Uncomment this if you want to add more stuff while debugging + # freeformType = types.attrsOf types.raw; options = { # Those options are interfaced by the CLI # We don't specify the type here, for better performance. diff --git a/lib/build-clan/module.nix b/lib/build-clan/module.nix index a3de32f2d..aee0a2b79 100644 --- a/lib/build-clan/module.nix +++ b/lib/build-clan/module.nix @@ -242,14 +242,14 @@ in clanInternals = { inherit inventoryClass; + # TODO: remove this after a month or so + # This is here for backwards compatibility for older CLI versions inventory = config.inventory; # TODO: unify this interface # We should have only clan.modules. (consistent with clan.templates) inherit (clan-core) clanModules; - templates = config.templates; - secrets = config.secrets; # machine specifics diff --git a/pkgs/clan-cli/clan_cli/completions.py b/pkgs/clan-cli/clan_cli/completions.py index 864e1a31e..127f8f2de 100644 --- a/pkgs/clan-cli/clan_cli/completions.py +++ b/pkgs/clan-cli/clan_cli/completions.py @@ -49,19 +49,10 @@ def complete_machines( flake = clan_dir_result else: flake = "." - services_result = json.loads( - run( - nix_eval( - flags=[ - f"{flake}#clanInternals.machines.x86_64-linux", - "--apply", - "builtins.attrNames", - ], - ), - ).stdout.strip() - ) - machines.extend(services_result) + inventory = InventoryStore(Flake(str(flake))).read() + machines.extend(inventory.get("machines", {}).keys()) + except subprocess.CalledProcessError: pass diff --git a/pkgs/clan-cli/clan_lib/flake/flake.py b/pkgs/clan-cli/clan_lib/flake/flake.py index cb4c52020..d8184e258 100644 --- a/pkgs/clan-cli/clan_lib/flake/flake.py +++ b/pkgs/clan-cli/clan_lib/flake/flake.py @@ -792,62 +792,6 @@ class Flake: if self.flake_cache_path: self._cache.save_to_file(self.flake_cache_path) - def uncached_nix_eval_with_args( - self, - attr_path: str, - f_args: dict[str, str], - nix_options: list[str] | None = None, - ) -> str: - """ - Calls a nix function with the provided arguments 'f_args' - The argument must be an attribute set. - - Args: - attr_path (str): The attribute path to the nix function - f_args (dict[str, nix_expr]): A python dictionary mapping from the name of the argument to a raw nix expression. - - Example - - flake.uncached_nix_eval_with_args( - "clanInternals.evalServiceSchema", - { "moduleSpec": "{ name = \"hello-world\"; input = null; }" } - ) - > '{ ...JSONSchema... }' - - """ - from clan_lib.cmd import Log, RunOpts, run - from clan_lib.nix import ( - nix_eval, - nix_test_store, - ) - - # Always prefetch, so we don't get any stale information - self.prefetch() - - if nix_options is None: - nix_options = [] - - arg_expr = "{" - for arg_name, arg_value in f_args.items(): - arg_expr += f" {arg_name} = {arg_value}; " - arg_expr += "}" - - nix_code = f""" - let - flake = builtins.getFlake "path:{self.store_path}?narHash={self.hash}"; - in - flake.{attr_path} {arg_expr} - """ - if tmp_store := nix_test_store(): - nix_options += ["--store", str(tmp_store)] - nix_options.append("--impure") - - output = run( - nix_eval(["--expr", nix_code, *nix_options]), RunOpts(log=Log.NONE) - ).stdout.strip() - - return output - def precache( self, selectors: list[str],