ctucx.git: nixfiles

ctucx' nixfiles

commit 07d065db78603078373daee0a0474e81da3c53df
parent 2479cac9eeb26db6f477f4209cd6d0ba70bce902
Author: Leah (ctucx) <leah@ctu.cx>
Date: Sun, 13 Feb 2022 13:57:29 +0100

services/syncthing: intelligent(TM) determination of share-devices
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/configurations/services/syncthing.nix b/configurations/services/syncthing.nix
@@ -54,8 +54,10 @@ let
 
   deviceNames       = builtins.attrNames (lib.filterAttrs isCurrentHost devices);
   isaDeviceNames    = builtins.attrNames isaDevices;
+  shareDeviceNames  = share: builtins.attrNames (lib.filterAttrs (n: v: builtins.elem share v) enabledShares);
 
   filterCurrentHost = devices: lib.remove config.networking.hostName devices;
+
   isCurrentHost     = n: v: n != config.networking.hostName;
   isShareEnabled    = share:
     if builtins.hasAttr config.networking.hostName enabledShares then

@@ -101,7 +103,7 @@ in {
           enable            = isShareEnabled "${id}";
           id                = "ctucx-audiobooks-orig";
           label             = "Audiobooks (Originals}";
-          devices           = filterCurrentHost [ "desastro" "lollo" "stasicontainer" ];
+          devices           = filterCurrentHost (shareDeviceNames "${id}");
           versioning.type   = "trashcan";
           versioning.params = {
             cleanoutDays = "10";

@@ -142,7 +144,7 @@ in {
           enable            = isShareEnabled "${id}";
           id                = "ctucx-music-orig";
           label             = "Music (Originals)";
-          devices           = filterCurrentHost [ "desastro" "lollo" "stasicontainer" ];
+          devices           = filterCurrentHost (shareDeviceNames "${id}");
           versioning.type   = "trashcan";
           versioning.params = {
             cleanoutDays = "10";

@@ -173,7 +175,7 @@ in {
           enable            = isShareEnabled "${id}";
           id                = "ctucx-media";
           label             = "Media (legacy)";
-          devices           = filterCurrentHost [ "desastro" "lollo" ];
+          devices           = filterCurrentHost (shareDeviceNames "${id}");
           versioning.type   = "trashcan";
           versioning.params = {
             cleanoutDays = "15";

@@ -184,7 +186,7 @@ in {
           enable            = isShareEnabled "${id}";
           id                = "ctucx-windoofs";
           label             = "Windows-Stuff";
-          devices           = filterCurrentHost [ "desastro" "lollo" ];
+          devices           = filterCurrentHost (shareDeviceNames "${id}");
           versioning.type   = "trashcan";
           versioning.params = {
             cleanoutDays = "10";