summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2024-12-06 22:15:26 +0100
committerMel <einebeere@gmail.com>2024-12-06 22:15:26 +0100
commit4d2e7db5cf8e89590c9f8b342cc487d500c0e822 (patch)
treecfad7a3ef584b0403b277add4f65007b8283a666
parent9fa61804efa7d4230122131893f0bddf9538d87a (diff)
downloadnetwork-4d2e7db5cf8e89590c9f8b342cc487d500c0e822.tar.zst
network-4d2e7db5cf8e89590c9f8b342cc487d500c0e822.zip
Server-side syncthing configuration
Signed-off-by: Mel <einebeere@gmail.com>
-rw-r--r--machines/renard/default.nix1
-rw-r--r--modules/syncthing.nix69
2 files changed, 70 insertions, 0 deletions
diff --git a/machines/renard/default.nix b/machines/renard/default.nix
index e44c776..826e92f 100644
--- a/machines/renard/default.nix
+++ b/machines/renard/default.nix
@@ -9,6 +9,7 @@
../../modules/www.nix
../../modules/git.nix
+ ../../modules/syncthing.nix
../../services/cgit.nix
../../services/minecraft.nix
diff --git a/modules/syncthing.nix b/modules/syncthing.nix
new file mode 100644
index 0000000..3210e03
--- /dev/null
+++ b/modules/syncthing.nix
@@ -0,0 +1,69 @@
+{
+ lib,
+ me,
+ config,
+ ...
+}:
+
+let
+ inherit (config.users.users) mel;
+
+ defaultSyncthingPort = "8384";
+in
+{
+ # server-side
+ services.syncthing = {
+ enable = true;
+ # do not open any firewall ports,
+ # we only want access through the tailnet
+ openDefaultPorts = false;
+ guiAddress = "${me.tailscale.ip}:${defaultSyncthingPort}";
+
+ user = "mel";
+ dataDir = "${mel.home}/sync";
+ configDir = "${mel.home}/.config/syncthing";
+
+ # only take declarative configuration below
+ overrideDevices = true;
+ overrideFolders = true;
+ settings = {
+ devices = {
+ bismuth.id = "MXC4UQG-PRZESJ3-AQYGWNG-EMCI44Q-UC7YFNP-6ZDF3SA-NLZCVUH-FQAK6QK";
+ graphite.id = "THWA2HN-BZ4URXS-P5PKAJY-YEBYQSH-2MUDKXC-CL3YQ2A-VHFUPCE-ROHQNQ7";
+ };
+
+ # TODO: these are duplciated from the client configuration.
+ # maybe we should semi-merge the two??
+ folders =
+ let
+ clientFolders = [
+ "desktop"
+ "documents"
+ "pictures"
+ "music"
+ "videos"
+ "thoughts"
+ "code"
+ "scripts"
+ "projects"
+ ];
+
+ commonFolder = name: {
+ path = "~/sync/${name}";
+ type = "receiveonly";
+ versioning = {
+ type = "staggered";
+ params = {
+ cleanInterval = toString (60 * 60);
+ maxAge = toString (14 * 24 * 60 * 60);
+ };
+ };
+ };
+ in
+ lib.genAttrs clientFolders commonFolder;
+
+ # no telemetry
+ options.urAccepted = -1;
+ };
+ };
+}