From 2e38b314add539d38a0fd895a98595516cb38c3e Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Fri, 4 Jul 2025 10:02:06 +0200 Subject: [PATCH] lib/get_host: improve abstraction, turn missconfiguration into a warning Motivation: A warning should encourage consistent usage of inventory.machines setting targetHost inside the machine should be considered a custom override Changing the warning strings to avoid the term 'nix'/'json' both inventory and nixos machines are nix features --- pkgs/clan-cli/clan_lib/machines/machines.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/clan-cli/clan_lib/machines/machines.py b/pkgs/clan-cli/clan_lib/machines/machines.py index 5b2e4656a..80d8431aa 100644 --- a/pkgs/clan-cli/clan_lib/machines/machines.py +++ b/pkgs/clan-cli/clan_lib/machines/machines.py @@ -178,7 +178,7 @@ class Machine: @dataclass(frozen=True) class RemoteSource: data: Remote - source: Literal["inventory", "nix_machine"] + source: Literal["inventory", "machine"] @API.register @@ -191,15 +191,15 @@ def get_host( machine = Machine(name=name, flake=flake) inv_machine = machine.get_inv_machine() - source: Literal["inventory", "nix_machine"] = "inventory" + source: Literal["inventory", "machine"] = "inventory" host_str = inv_machine.get("deploy", {}).get(field) if host_str is None: - machine.debug( - f"'{field}' is not set in inventory, falling back to slower Nix config, set it either through the Nix or json interface to improve performance" + machine.warn( + f"'{field}' is not set in `inventory.machines.${name}.deploy.targetHost` - falling back to _slower_ nixos option: `clan.core.networking.targetHost`" ) host_str = machine.select(f'config.clan.core.networking."{field}"') - source = "nix_machine" + source = "machine" if not host_str: return None