diff --git a/pkgs/clan-cli/clan_cli/machines/machines.py b/pkgs/clan-cli/clan_cli/machines/machines.py index e46a1af3a..48a1d872d 100644 --- a/pkgs/clan-cli/clan_cli/machines/machines.py +++ b/pkgs/clan-cli/clan_cli/machines/machines.py @@ -33,6 +33,7 @@ class Machine: nix_options: list[str] = field(default_factory=list) cached_deployment: None | dict[str, Any] = None override_target_host: None | str = None + override_build_host: None | str = None host_key_check: HostKeyCheck = HostKeyCheck.STRICT _eval_cache: dict[str, str] = field(default_factory=dict) @@ -95,14 +96,9 @@ class Machine: @property def target_host_address(self) -> str: - # deploymentAddress is deprecated. - val = ( - self.override_target_host - or self.deployment.get("targetHost") - or self.deployment.get("deploymentAddress") - ) + val = self.override_target_host or self.deployment.get("targetHost") if val is None: - msg = f"'TargetHost' is not set for machine '{self.name}'" + msg = f"'targetHost' is not set for machine '{self.name}'" raise ClanError( msg, description="See https://docs.clan.lol/getting-started/deploy/#setting-the-target-host for more information.", @@ -201,7 +197,7 @@ class Machine: The host where the machine is built and deployed from. Can be the same as the target host. """ - build_host = self.deployment.get("buildHost") + build_host = self.override_build_host or self.deployment.get("buildHost") if build_host is None: return self.target_host # enable ssh agent forwarding to allow the build host to access the target host diff --git a/pkgs/clan-cli/clan_cli/machines/update.py b/pkgs/clan-cli/clan_cli/machines/update.py index dd9159f0c..aec523f82 100644 --- a/pkgs/clan-cli/clan_cli/machines/update.py +++ b/pkgs/clan-cli/clan_cli/machines/update.py @@ -105,6 +105,8 @@ def update_machines(base_path: str, machines: list[InventoryMachine]) -> None: raise ClanError(msg) # Copy targetHost to machine m.override_target_host = machine.deploy.targetHost + # Would be nice to have? + # m.override_build_host = machine.deploy.buildHost group_machines.append(m) deploy_machine(MachineGroup(group_machines)) @@ -197,6 +199,7 @@ def update(args: argparse.Namespace) -> None: name=args.machines[0], flake=args.flake, nix_options=args.option ) machine.override_target_host = args.target_host + machine.override_build_host = args.build_host machine.host_key_check = HostKeyCheck.from_str(args.host_key_check) machines.append(machine) @@ -215,6 +218,7 @@ def update(args: argparse.Namespace) -> None: ignored_machines.append(machine) continue machine.host_key_check = HostKeyCheck.from_str(args.host_key_check) + machine.override_build_host = args.build_host machines.append(machine) if not machines and ignored_machines != []: @@ -230,6 +234,7 @@ def update(args: argparse.Namespace) -> None: else: machines = get_selected_machines(args.flake, args.option, args.machines) for machine in machines: + machine.override_build_host = args.build_host machine.host_key_check = HostKeyCheck.from_str(args.host_key_check) host_group = MachineGroup(machines) @@ -258,4 +263,9 @@ def register_update_parser(parser: argparse.ArgumentParser) -> None: type=str, help="Address of the machine to update, in the format of user@host:1234.", ) + parser.add_argument( + "--build-host", + type=str, + help="Address of the machine to build the flake, in the format of user@host:1234.", + ) parser.set_defaults(func=update)