tasks.py: use copy instead of archive for deploy

this is faster but it assumes that the flake inputs can be substituted on the target
This commit is contained in:
zowoq 2025-01-05 10:38:42 +10:00
parent e41ce7ba70
commit dabf0339b9

View file

@ -30,13 +30,17 @@ def deploy(c: Any, hosts: str) -> None:
command = "sudo nixos-rebuild" command = "sudo nixos-rebuild"
target = f"{h.host}" target = f"{h.host}"
res = h.run_local( res = subprocess.run(
["nix", "flake", "archive", "--to", f"ssh://{target}", "--json"], ["nix", "flake", "metadata", "--json"],
text=True,
check=True,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
) )
data = json.loads(res.stdout) data = json.loads(res.stdout)
path = data["path"] path = data["path"]
h.run_local(f"nix copy --to ssh://{target} {path}")
hostname = h.host.replace(".nix-community.org", "") hostname = h.host.replace(".nix-community.org", "")
h.run( h.run(
f"{command} switch --option accept-flake-config true --flake {path}#{hostname}" f"{command} switch --option accept-flake-config true --flake {path}#{hostname}"