From 447094bb019b7783c53fc60fdb7e2a866c2370a2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= <joerg@thalheim.io>
Date: Mon, 6 Mar 2023 16:42:08 +0100
Subject: [PATCH] change deployment to use flake only

---
 tasks.py | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/tasks.py b/tasks.py
index 2a8d0de..882a3d4 100644
--- a/tasks.py
+++ b/tasks.py
@@ -9,15 +9,6 @@ from typing import Any, List
 from deploykit import DeployGroup, DeployHost
 from invoke import task
 
-RSYNC_EXCLUDES = [
-    ".direnv",
-    ".git",
-    ".mypy-cache",
-    ".ruff_cache",
-    ".terraform",
-    "result*",
-]
-
 
 def deploy_nixos(hosts: List[DeployHost]) -> None:
     """
@@ -25,11 +16,18 @@ def deploy_nixos(hosts: List[DeployHost]) -> None:
     """
     g = DeployGroup(hosts)
 
+    res = subprocess.run(
+        ["nix", "flake", "metadata", "--json"],
+        check=True,
+        text=True,
+        stdout=subprocess.PIPE,
+    )
+    data = json.loads(res.stdout)
+    path = data["path"]
+
     def deploy(h: DeployHost) -> None:
         target = f"{h.user or 'root'}@{h.host}"
-        h.run_local(
-            f"rsync {' --exclude '.join([''] + RSYNC_EXCLUDES)} -vaF --delete -e ssh . {target}:/etc/nixos"
-        )
+        h.run_local(f"rsync -vaF --delete -e ssh {path}/ {target}:/etc/nixos")
 
         h.run("nixos-rebuild switch --option accept-flake-config true")