Merge pull request 'clan-cli: Fix breakage if machines update' (#2221) from Qubasa/clan-core:Qubasa-main into main
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import argparse
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import shlex
|
||||
import sys
|
||||
|
||||
@@ -32,7 +33,7 @@ def is_path_input(node: dict[str, dict[str, str]]) -> bool:
|
||||
|
||||
def upload_sources(machine: Machine, always_upload_source: bool = False) -> str:
|
||||
host = machine.build_host
|
||||
env = host.nix_ssh_env()
|
||||
env = host.nix_ssh_env(os.environ.copy())
|
||||
|
||||
if not always_upload_source:
|
||||
flake_url = (
|
||||
@@ -119,8 +120,6 @@ def deploy_machine(machines: MachineGroup) -> None:
|
||||
machine,
|
||||
)
|
||||
|
||||
env = host.nix_ssh_env()
|
||||
|
||||
cmd = [
|
||||
"nixos-rebuild",
|
||||
"switch",
|
||||
@@ -142,6 +141,7 @@ def deploy_machine(machines: MachineGroup) -> None:
|
||||
target_host = f"{target_host.user or 'root'}@{target_host.host}"
|
||||
cmd.extend(["--target-host", target_host])
|
||||
|
||||
env = host.nix_ssh_env(None)
|
||||
ret = host.run(cmd, extra_env=env, check=False)
|
||||
# re-retry switch if the first time fails
|
||||
if ret.returncode != 0:
|
||||
|
||||
@@ -513,8 +513,9 @@ class Host:
|
||||
timeout=timeout,
|
||||
)
|
||||
|
||||
def nix_ssh_env(self) -> dict[str, str]:
|
||||
env = os.environ.copy()
|
||||
def nix_ssh_env(self, env: dict[str, str] | None) -> dict[str, str]:
|
||||
if env is None:
|
||||
env = {}
|
||||
env["NIX_SSHOPTS"] = " ".join(self.ssh_cmd_opts())
|
||||
return env
|
||||
|
||||
|
||||
Reference in New Issue
Block a user