summary refs log tree commit diff
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2024-12-06 04:24:38 +0100
committerMel <einebeere@gmail.com>2024-12-06 04:24:38 +0100
commitb36d35552d39d412d970b077882ee07f2d1ec4fc (patch)
treecf93ed9737946e5446ef8d12b68a281234b1dd18
parent79c1471fba9f5102649575b0698c5ab723169c71 (diff)
downloadminerals-b36d35552d39d412d970b077882ee07f2d1ec4fc.tar.zst
minerals-b36d35552d39d412d970b077882ee07f2d1ec4fc.zip
Syncthing client-side configuration
Signed-off-by: Mel <einebeere@gmail.com>
-rw-r--r--machines/bismuth/default.nix1
-rw-r--r--machines/graphite/default.nix2
-rw-r--r--modules/syncthing.nix71
3 files changed, 74 insertions, 0 deletions
diff --git a/machines/bismuth/default.nix b/machines/bismuth/default.nix
index 448ea21..b791e3a 100644
--- a/machines/bismuth/default.nix
+++ b/machines/bismuth/default.nix
@@ -7,6 +7,7 @@
     ./hardware.nix
     ./devices.nix
 
+    ../../modules/syncthing.nix
     ../../modules/nvidia.nix
   ];
 
diff --git a/machines/graphite/default.nix b/machines/graphite/default.nix
index 4bbb938..03934ff 100644
--- a/machines/graphite/default.nix
+++ b/machines/graphite/default.nix
@@ -6,6 +6,8 @@
 
     ./hardware.nix
     ./devices.nix
+
+    ../../modules/syncthing.nix
   ];
 
   networking.hostName = "Graphite";
diff --git a/modules/syncthing.nix b/modules/syncthing.nix
new file mode 100644
index 0000000..71cd3ac
--- /dev/null
+++ b/modules/syncthing.nix
@@ -0,0 +1,71 @@
+{ lib, ... }:
+
+let
+  commonFolderSettings = {
+    devices = [
+      "bismuth"
+      "graphite"
+      "renard"
+    ];
+    # clean every hour, keep files that are less than 14 days old.
+    versioning = {
+      type = "staggered";
+      params = {
+        cleanInterval = toString (60 * 60);
+        maxAge = toString (14 * 24 * 60 * 60);
+      };
+    };
+  };
+
+  folder = name: path: {
+    ${name} = {
+      inherit path;
+    } // commonFolderSettings;
+  };
+
+in
+{
+  # client-side
+  services.syncthing = {
+    enable = true;
+    openDefaultPorts = true;
+
+    dataDir = "/home/mel";
+    configDir = "/home/mel/.config/syncthing";
+
+    user = "mel";
+    group = "users";
+
+    # only take declarative configuration below
+    overrideDevices = true;
+    overrideFolders = true;
+    settings = {
+      devices = {
+        # clients
+        bismuth.id = "MXC4UQG-PRZESJ3-AQYGWNG-EMCI44Q-UC7YFNP-6ZDF3SA-NLZCVUH-FQAK6QK";
+        graphite.id = "THWA2HN-BZ4URXS-P5PKAJY-YEBYQSH-2MUDKXC-CL3YQ2A-VHFUPCE-ROHQNQ7";
+
+        # server, defined in network
+        renard.id = "XLGIQ7O-NZ6RRJT-EOEZHGT-SCX5MMM-NCC3WWO-D4QLBY5-EP5ZNKA-CL74XAU";
+      };
+
+      folders = lib.mergeAttrsList [
+        # freedesktop.org user directories
+        (folder "desktop" "~/Desktop")
+        (folder "documents" "~/Documents")
+        (folder "pictures" "~/Pictures")
+        (folder "music" "~/Music")
+        (folder "videos" "~/Videos")
+
+        # other custom directories
+        (folder "thoughts" "~/Thoughts")
+        (folder "code" "~/Code")
+        (folder "scripts" "~/Scripts")
+        (folder "projects" "~/Projects")
+      ];
+
+      # no telemetry
+      options.urAccepted = -1;
+    };
+  };
+}