ctucx.git: nixfiles

ctucx' nixfiles

commit 7bd551f171953c64353195a78865b8dca3f8ba15
parent 26fd83c463f495c942e2ebbe7dd5285fdfc257e5
Author: Leah (ctucx) <leah@ctu.cx>
Date: Wed, 12 Jan 2022 17:55:05 +0100

programs/syncthing: setup shares dynamicly for each host
1 file changed, 133 insertions(+), 5 deletions(-)
M
configurations/programs/syncthing.nix
|
138
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
diff --git a/configurations/programs/syncthing.nix b/configurations/programs/syncthing.nix
@@ -1,9 +1,137 @@
-{ ... }:
+{ config, lib, ... }:
 
-{
-  home-manager.users.leah = {
-    services = {
-      syncthing.enable = true;
+let
+  devices = {
+  };
+
+  isaDevices = {
+  };
+
+  isCurrentHost  = n: v: n != config.networking.hostName;
+  deviceNames    = builtins.attrNames (lib.filterAttrs isCurrentHost devices);
+  isaDeviceNames = builtins.attrNames isaDevices;
+
+in {
+  services = {
+    syncthing = {
+      enable           = true;
+      openDefaultPorts = true;
+      user             = "leah";
+      group            = "users";
+
+      dataDir          = "/home/leah";
+      configDir        = "/home/leah/.config/syncthing";
+
+      devices          = (lib.mkMerge [ (lib.filterAttrs isCurrentHost devices) isaDevices]);
+
+      folders = {
+
+        "/home/leah/Audiobooks (Originals)" = {
+          enable            = (if config.networking.hostName == "stasicontainer" then true else false);
+          id                = "ctucx-audiobooks-orig";
+          label             = "Audiobooks (Originals}";
+          devices           = [ "desastro" "lollo" ];
+          versioning.type   = "trashcan";
+          versioning.params = {
+            cleanoutDays = "10";
+          };
+        };
+
+        "/home/leah/Audiobooks" = {
+          id                = "ctucx-audiobooks";
+          label             = "Audiobooks";
+          devices           = deviceNames;
+          versioning.type   = "trashcan";
+          versioning.params = {
+            cleanoutDays = "10";
+          };
+        };
+
+        "/home/leah/Documents" = {
+          id                = "ctucx-documents";
+          label             = "Documents";
+          devices           = deviceNames;
+          versioning.type   = "trashcan";
+          versioning.params = {
+            cleanoutDays = "30";
+          };
+        };
+
+        "/home/leah/Music" = {
+          id                = "ctucx-music";
+          label             = "Music";
+          devices           = deviceNames;
+          versioning.type   = "trashcan";
+          versioning.params = {
+            cleanoutDays = "10";
+          };
+        };
+
+        "/home/leah/Music (Originals)" = {
+          enable            = (if config.networking.hostName == "stasicontainer" then true else false);
+          id                = "ctucx-music-orig";
+          label             = "Music (Originals)";
+          devices           = [ "desastro" "lollo" ];
+          versioning.type   = "trashcan";
+          versioning.params = {
+            cleanoutDays = "10";
+          };
+        };
+
+        "/home/leah/Pictures" = {
+          id                = "ctucx-pictures";
+          label             = "Pictures";
+          devices           = deviceNames;
+          versioning.type   = "trashcan";
+          versioning.params = {
+            cleanoutDays = "30";
+          };
+        };
+
+        "/home/leah/Videos" = {
+          id                = "ctucx-videos";
+          label             = "Videos";
+          devices           = deviceNames;
+          versioning.type   = "trashcan";
+          versioning.params = {
+            cleanoutDays = "5";
+          };
+        };
+
+
+
+
+        "/home/leah/Bahn-Richtlinien" = {
+          id                = "Bahn-Richtlinien";
+          label             = "Bahn-Richtlinien";
+          devices           = (lib.mkMerge [ deviceNames isaDeviceNames]);
+          versioning.type   = "trashcan";
+          versioning.params = {
+            cleanoutDays = "5";
+          };
+        };
+
+        "/home/leah/Cutieshare" = {
+          id                = "cutieshare";
+          label             = "Cutieshare";
+          devices           = (lib.mkMerge [ deviceNames isaDeviceNames]);
+          versioning.type   = "trashcan";
+          versioning.params = {
+            cleanoutDays = "5";
+          };
+        };
+
+        "/home/leah/Wiki" = {
+          id                = "ctucx-wiki";
+          label             = "Wiki";
+          devices           = (lib.mkMerge [ deviceNames isaDeviceNames]);
+          versioning.type   = "staggered";
+          versioning.params = {
+            maxAge = "2592000";
+          };
+        };
+
+      };
     };
   };
 }