Merge pull request 'fix build host with sudo' (#4267) from fix-sudo into main
Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/4267
This commit is contained in:
@@ -59,7 +59,7 @@
|
|||||||
name = "flash";
|
name = "flash";
|
||||||
nodes.target = {
|
nodes.target = {
|
||||||
virtualisation.emptyDiskImages = [ 4096 ];
|
virtualisation.emptyDiskImages = [ 4096 ];
|
||||||
virtualisation.memorySize = 3000;
|
virtualisation.memorySize = 4096;
|
||||||
environment.systemPackages = [ self.packages.${pkgs.system}.clan-cli ];
|
environment.systemPackages = [ self.packages.${pkgs.system}.clan-cli ];
|
||||||
environment.etc."install-closure".source = "${closureInfo}/store-paths";
|
environment.etc."install-closure".source = "${closureInfo}/store-paths";
|
||||||
|
|
||||||
|
|||||||
@@ -119,11 +119,9 @@ def run_machine_update(
|
|||||||
with ExitStack() as stack:
|
with ExitStack() as stack:
|
||||||
target_host = stack.enter_context(target_host.ssh_control_master())
|
target_host = stack.enter_context(target_host.ssh_control_master())
|
||||||
|
|
||||||
if build_host is not None:
|
if build_host:
|
||||||
build_host = stack.enter_context(build_host.ssh_control_master())
|
build_host = stack.enter_context(build_host.ssh_control_master())
|
||||||
|
|
||||||
host = build_host or target_host
|
|
||||||
|
|
||||||
sudo_host = stack.enter_context(target_host.become_root())
|
sudo_host = stack.enter_context(target_host.become_root())
|
||||||
|
|
||||||
generate_facts([machine], service=None, regenerate=False)
|
generate_facts([machine], service=None, regenerate=False)
|
||||||
@@ -132,7 +130,10 @@ def run_machine_update(
|
|||||||
upload_secrets(machine, sudo_host)
|
upload_secrets(machine, sudo_host)
|
||||||
upload_secret_vars(machine, sudo_host)
|
upload_secret_vars(machine, sudo_host)
|
||||||
|
|
||||||
path = upload_sources(machine, sudo_host)
|
if build_host:
|
||||||
|
path = upload_sources(machine, build_host)
|
||||||
|
else:
|
||||||
|
path = upload_sources(machine, target_host)
|
||||||
|
|
||||||
nix_options = machine.flake.nix_options if machine.flake.nix_options else []
|
nix_options = machine.flake.nix_options if machine.flake.nix_options else []
|
||||||
|
|
||||||
@@ -174,11 +175,13 @@ def run_machine_update(
|
|||||||
*nix_options,
|
*nix_options,
|
||||||
]
|
]
|
||||||
|
|
||||||
if become_root:
|
if become_root and not build_host:
|
||||||
host = sudo_host
|
target_host = sudo_host
|
||||||
|
|
||||||
remote_env = host.nix_ssh_env(control_master=False)
|
deploy_host = build_host if build_host else target_host
|
||||||
ret = host.run(
|
|
||||||
|
remote_env = deploy_host.nix_ssh_env(control_master=False)
|
||||||
|
ret = deploy_host.run(
|
||||||
switch_cmd,
|
switch_cmd,
|
||||||
RunOpts(
|
RunOpts(
|
||||||
check=False,
|
check=False,
|
||||||
@@ -205,7 +208,7 @@ def run_machine_update(
|
|||||||
machine.info(
|
machine.info(
|
||||||
"Mobile machine detected, applying workaround deployment method"
|
"Mobile machine detected, applying workaround deployment method"
|
||||||
)
|
)
|
||||||
ret = host.run(
|
ret = deploy_host.run(
|
||||||
["nixos--rebuild", "test", *nix_options] if is_mobile else switch_cmd,
|
["nixos--rebuild", "test", *nix_options] if is_mobile else switch_cmd,
|
||||||
RunOpts(
|
RunOpts(
|
||||||
log=Log.BOTH,
|
log=Log.BOTH,
|
||||||
|
|||||||
Reference in New Issue
Block a user