clan-cli: Fix deployment as non root with a buildHost set

This commit is contained in:
Qubasa
2025-03-28 18:47:36 +01:00
parent 94781bb358
commit 8e2005f38c

View File

@@ -152,6 +152,7 @@ def deploy_machines(machines: list[Machine]) -> None:
"--flake", "--flake",
f"{path}#{machine.name}", f"{path}#{machine.name}",
] ]
switch_cmd = ["nixos-rebuild", "switch", *nix_options] switch_cmd = ["nixos-rebuild", "switch", *nix_options]
test_cmd = ["nixos-rebuild", "test", *nix_options] test_cmd = ["nixos-rebuild", "test", *nix_options]
@@ -160,6 +161,10 @@ def deploy_machines(machines: list[Machine]) -> None:
switch_cmd.extend(["--target-host", target_host.target]) switch_cmd.extend(["--target-host", target_host.target])
test_cmd.extend(["--target-host", target_host.target]) test_cmd.extend(["--target-host", target_host.target])
if target_host and target_host.user != "root":
switch_cmd.extend(["--use-remote-sudo"])
test_cmd.extend(["--use-remote-sudo"])
env = host.nix_ssh_env(None) env = host.nix_ssh_env(None)
ret = host.run( ret = host.run(
switch_cmd, switch_cmd,