about summary refs log tree commit diff
path: root/modules/nixos/syncthing.nix
diff options
context:
space:
mode:
authorAzat Bahawi <azat@bahawi.net>2024-03-31 21:29:27 +0300
committerAzat Bahawi <azat@bahawi.net>2024-03-31 21:29:27 +0300
commit9a5427e3a0c0ccf2a82dc503149a26b23fbd6004 (patch)
treef28beec29deeea36038615a8fb98a810891940b5 /modules/nixos/syncthing.nix
parent2024-03-19 (diff)
2024-03-31
Diffstat (limited to '')
-rw-r--r--modules/nixos/syncthing.nix62
1 files changed, 34 insertions, 28 deletions
diff --git a/modules/nixos/syncthing.nix b/modules/nixos/syncthing.nix
index ecc983f..74d4afe 100644
--- a/modules/nixos/syncthing.nix
+++ b/modules/nixos/syncthing.nix
@@ -6,9 +6,11 @@
   this,
   ...
 }:
-with lib; let
+with lib;
+let
   cfg = config.nixfiles.modules.syncthing;
-in {
+in
+{
   options.nixfiles.modules.syncthing = {
     enable = mkEnableOption "Syncthing";
 
@@ -74,7 +76,8 @@ in {
             insecureSkipHostcheck = this.isHeadless;
           };
 
-          devices = mapAttrs (name: attr:
+          devices = mapAttrs (
+            name: attr:
             mkIf (attr.syncthing.id != null && hasAttr "wireguard" attr) {
               inherit (attr.syncthing) id;
               compression = "metadata";
@@ -82,30 +85,33 @@ in {
               address = "tcp://${name}.${config.networking.domain}:22000";
               autoAcceptFolders = true;
               untrusted = false;
-            })
-          my.configurations;
-
-          folders = let
-            filterDevices = f:
-              attrNames (filterAttrs (_: attr:
-                (attr.hostname != this.hostname)
-                && (attr.syncthing.id != null)
-                && f attr)
-              my.configurations);
-            all = filterDevices (_: true);
-            notHeadless = filterDevices (attr: !attr.isHeadless);
-            notOther = filterDevices (attr: !attr.isOther);
-
-            simple = {
-              type = "simple";
-              params.keep = "5";
-            };
-            trashcan = {
-              type = "trashcan";
-              params.cleanoutDays = "7";
-            };
-          in
-            with config.hm.xdg.userDirs; {
+            }
+          ) my.configurations;
+
+          folders =
+            let
+              filterDevices =
+                f:
+                attrNames (
+                  filterAttrs (
+                    _: attr: (attr.hostname != this.hostname) && (attr.syncthing.id != null) && f attr
+                  ) my.configurations
+                );
+              all = filterDevices (_: true);
+              notHeadless = filterDevices (attr: !attr.isHeadless);
+              notOther = filterDevices (attr: !attr.isOther);
+
+              simple = {
+                type = "simple";
+                params.keep = "5";
+              };
+              trashcan = {
+                type = "trashcan";
+                params.cleanoutDays = "7";
+              };
+            in
+            with config.hm.xdg.userDirs;
+            {
               share = {
                 path = publicShare;
                 devices = notHeadless;
@@ -145,7 +151,7 @@ in {
     (mkIf this.isHeadless {
       nixfiles.modules.nginx = {
         enable = true;
-        upstreams.syncthing.servers.${config.services.syncthing.guiAddress} = {};
+        upstreams.syncthing.servers.${config.services.syncthing.guiAddress} = { };
         virtualHosts.${cfg.domain} = {
           locations."/".proxyPass = "http://syncthing";
           extraConfig = libNginx.config.internalOnly;

Consider giving Nix/NixOS a try! <3