From fe43be7e3ba5c868f5bda21bdb260bbf0c40a7a1 Mon Sep 17 00:00:00 2001
From: willifan <willifan@proton.me>
Date: Sat, 3 Aug 2024 15:36:08 +0200
Subject: [PATCH] added syncthing

---
 hosts/Anton/default.nix                       |  1 +
 hosts/Anton/docker.nix.save                   |  9 ++++
 hosts/Anton/firewall.nix                      |  2 +-
 hosts/Anton/syncthing.nix                     | 54 +++++++++++++++++++
 hosts/desktop/default.nix                     |  1 +
 .../common => hosts/desktop}/syncthing.nix    |  4 +-
 users/willifan/common/default.nix             |  3 +-
 7 files changed, 69 insertions(+), 5 deletions(-)
 create mode 100644 hosts/Anton/docker.nix.save
 create mode 100644 hosts/Anton/syncthing.nix
 rename {users/willifan/common => hosts/desktop}/syncthing.nix (92%)

diff --git a/hosts/Anton/default.nix b/hosts/Anton/default.nix
index 2f37475..1a0d437 100644
--- a/hosts/Anton/default.nix
+++ b/hosts/Anton/default.nix
@@ -10,6 +10,7 @@
     ./gitea.nix
     ./hardware-configuration.nix
     ./radicale.nix
+    ./syncthing.nix
 
   ];
 
diff --git a/hosts/Anton/docker.nix.save b/hosts/Anton/docker.nix.save
new file mode 100644
index 0000000..1798fdf
--- /dev/null
+++ b/hosts/Anton/docker.nix.save
@@ -0,0 +1,9 @@
+{ pkgs, ... }:
+{
+
+  virtualisation.docker = {
+    enable = true;
+    storageDriver = "btrfs";
+  };
+
+}
diff --git a/hosts/Anton/firewall.nix b/hosts/Anton/firewall.nix
index 2bde668..d5b7378 100644
--- a/hosts/Anton/firewall.nix
+++ b/hosts/Anton/firewall.nix
@@ -2,7 +2,7 @@
 {
   networking.firewall = {
     enable = true;
-    allowedTCPPorts = [ 22 80 443 3000 ];
+    allowedTCPPorts = [ 22 80 443 3000 8384 ];
     allowedUDPPorts = [ 22 80 443 ];
   };
 }
diff --git a/hosts/Anton/syncthing.nix b/hosts/Anton/syncthing.nix
new file mode 100644
index 0000000..375b315
--- /dev/null
+++ b/hosts/Anton/syncthing.nix
@@ -0,0 +1,54 @@
+{ pkgs, ... }:
+{
+  services.syncthing = {
+    enable =  true;
+    dataDir = "/mnt/data/services/syncthing/data";
+    configDir = "/mnt/data/services/syncthing/config";
+    overrideDevices = true;
+    overrideFolders = true;
+    openDefaultPorts = true;
+    guiAddress = "0.0.0.0:8384";
+    settings = {
+      gui = {
+        user = "willifan";
+        password = "temppassword";
+      };
+      devices = {
+        Lenni = { id = "XS6NR2Q-DHVB5G4-P43CHWR-TVBIY5A-FCIS7CU-S5UVNZA-5YPJYST-2EO2GAG"; };
+        Puenktchen = { id = "VP3YVIM-JNSZTXV-7AS7FA2-3W5QKH6-XOWXX7N-STUR4JR-PR6SPCV-HJZMAAN"; };
+      };
+      folders = {
+        "Documents" = {
+          id = "jtl6g-qjmwo";
+          path = "/mnt/data/services/syncthing/data/Documents";
+          devices = [ "Lenni" "Puenktchen" ];
+        };
+        "Enpass" = {
+          id = "ciksm-xsw4m";
+          path = "/mnt/data/services/syncthing/data/Enpass";
+          devices = [ "Lenni" "Puenktchen" ];
+        };
+        "Pictures" = {
+          id = "po4qj-q9t0t";
+          path = "/mnt/data/services/syncthing/data/Pictures";
+          devices = [ "Lenni" "Puenktchen" ];
+        };
+        "Videos" = {
+          id = "4wqf5-xasng";
+          path = "/mnt/data/services/syncthing/data/Videos";
+          devices = [ "Lenni" "Puenktchen" ];
+        };
+        "Notes" = {
+          id = "oc61n-iewgj";
+          path = "/mnt/data/services/syncthing/data/Notes";
+          devices = [ "Lenni" "Puenktchen" ];
+        };
+        "Music" = {
+          id = "xxh8a-3y2tq";
+          path = "/mnt/data/services/syncthing/data/Music";
+          devices = [ "Lenni" "Puenktchen" ];
+        };
+      };
+    };
+  };
+}
diff --git a/hosts/desktop/default.nix b/hosts/desktop/default.nix
index e92c023..cbc992d 100644
--- a/hosts/desktop/default.nix
+++ b/hosts/desktop/default.nix
@@ -5,6 +5,7 @@
     ./nix-ld.nix
     ./boot.nix
     ./printers.nix
+    ./syncthing.nix
   ];
   
   hardware.bluetooth.enable = true;
diff --git a/users/willifan/common/syncthing.nix b/hosts/desktop/syncthing.nix
similarity index 92%
rename from users/willifan/common/syncthing.nix
rename to hosts/desktop/syncthing.nix
index b37d77f..21d6cc9 100644
--- a/users/willifan/common/syncthing.nix
+++ b/hosts/desktop/syncthing.nix
@@ -13,7 +13,7 @@
         password = "temppassword";
       };
       devices = {
-        Anton = { id = "SGKTC3I-6IQZ5Z5-VAB76N6-L7DJ3TH-BMSZGKZ-MZPZHLO-KOVMZ2W-V5GQTA6"; };
+        Anton = { id = "WCDBADD-UPKCACI-X2YJOIO-5QC44PL-DBCR6TS-ADVQV33-HSMF32O-FOKMKAU"; };
       };
       folders = {
         "Documents" = {
@@ -49,4 +49,4 @@
       };
     };
   };
-}
\ No newline at end of file
+}
diff --git a/users/willifan/common/default.nix b/users/willifan/common/default.nix
index b30e716..5258742 100644
--- a/users/willifan/common/default.nix
+++ b/users/willifan/common/default.nix
@@ -6,10 +6,9 @@
     ./hyfetch.nix
     ./locales.nix
     #./ssh.nix
-    ./syncthing.nix
     ./user.nix
     #./zsh.nix
   ];
 
   home-manager.users.willifan.home.stateVersion = "23.11";
-}
\ No newline at end of file
+}