machines update: support local build

Now the user can pass `--build-host local`, to select the local machine as a build host, in which case no ssh is used.

This means the admin machine does not necessarily have ssh set up to itself, which was confusing for many users.

Also this makes it easier to re-use a well configured nix remote build setup which is only available on the local machine. Eg if `--build-host local` nix' defaults for remote builds on that machine will be utilized.
This commit is contained in:
DavHau
2025-07-29 18:44:25 +07:00
committed by Jörg Thalheim
parent b74193514d
commit af7ce9b8ed
3 changed files with 121 additions and 34 deletions

View File

@@ -18,7 +18,6 @@ from clan_lib.errors import ClanError
from clan_lib.machines.machines import Machine
from clan_lib.nix import nix_command, nix_metadata
from clan_lib.ssh.host import Host
from clan_lib.ssh.remote import Remote
log = logging.getLogger(__name__)
@@ -133,7 +132,7 @@ def run_machine_update(
if build_host is None:
build_host = target_host
else:
stack.enter_context(build_host.host_connection())
build_host = stack.enter_context(build_host.host_connection())
# Some operations require root privileges on the target host.
target_host_root = stack.enter_context(target_host.become_root())