From 0cfefb375c627be9e68c91cadaffeed97c8b6f83 Mon Sep 17 00:00:00 2001
From: zowoq <59103226+zowoq@users.noreply.github.com>
Date: Sun, 19 Jan 2025 09:56:35 +1000
Subject: [PATCH] tasks.py: use archive for deploy when the flake has file or
 path inputs

---
 tasks.py | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/tasks.py b/tasks.py
index be4269a..bba4314 100644
--- a/tasks.py
+++ b/tasks.py
@@ -39,7 +39,19 @@ def deploy(c: Any, hosts: str) -> None:
         data = json.loads(res.stdout)
         path = data["path"]
 
-        h.run_local(f"nix copy --to ssh://{target} {path}")
+        send = (
+            "nix flake archive"
+            if any(
+                (
+                    n.get("locked", {}).get("type") == "path"
+                    or n.get("locked", {}).get("url", "").startswith("file:")
+                )
+                for n in data["locks"]["nodes"].values()
+            )
+            else f"nix copy {path}"
+        )
+
+        h.run_local(f"{send} --to ssh://{target}")
 
         hostname = h.host.replace(".nix-community.org", "")
         h.run(