about summary refs log tree commit diff
path: root/nixpkgs/nixos/modules/services/networking/syncthing.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/nixos/modules/services/networking/syncthing.nix')
-rw-r--r--nixpkgs/nixos/modules/services/networking/syncthing.nix34
1 files changed, 27 insertions, 7 deletions
diff --git a/nixpkgs/nixos/modules/services/networking/syncthing.nix b/nixpkgs/nixos/modules/services/networking/syncthing.nix
index 89dae7bb3f86..d78a54a3327b 100644
--- a/nixpkgs/nixos/modules/services/networking/syncthing.nix
+++ b/nixpkgs/nixos/modules/services/networking/syncthing.nix
@@ -18,7 +18,10 @@ let
     fsWatcherEnabled = folder.watch;
     fsWatcherDelayS = folder.watchDelay;
     ignorePerms = folder.ignorePerms;
-  }) cfg.declarative.folders;
+  }) (filterAttrs (
+    _: folder:
+    folder.enable
+  ) cfg.declarative.folders);
 
   # get the api key by parsing the config.xml
   getApiKey = pkgs.writers.writeDash "getAPIKey" ''
@@ -102,13 +105,12 @@ in {
           description = ''
             Peers/devices which syncthing should communicate with.
           '';
-          example = [
-            {
-              name = "bigbox";
+          example = {
+            bigbox = {
               id = "7CFNTQM-IMTJBHJ-3UWRDIU-ZGQJFR6-VCXZ3NB-XUH3KZO-N52ITXR-LAIYUAU";
               addresses = [ "tcp://192.168.0.10:51820" ];
-            }
-          ];
+            };
+          };
           type = types.attrsOf (types.submodule ({ config, ... }: {
             options = {
 
@@ -166,9 +168,25 @@ in {
           description = ''
             folders which should be shared by syncthing.
           '';
+          example = {
+            "/home/user/sync" = {
+              id = "syncme";
+              devices = [ "bigbox" ];
+            };
+          };
           type = types.attrsOf (types.submodule ({ config, ... }: {
             options = {
 
+              enable = mkOption {
+                type = types.bool;
+                default = true;
+                description = ''
+                  share this folder.
+                  This option is useful when you want to define all folders
+                  in one place, but not every machine should share all folders.
+                '';
+              };
+
               path = mkOption {
                 type = types.str;
                 default = config._module.args.name;
@@ -408,7 +426,9 @@ in {
           '';
         };
       };
-      syncthing-init = {
+      syncthing-init = mkIf (
+        cfg.declarative.devices != {} || cfg.declarative.folders != {}
+      ) {
         after = [ "syncthing.service" ];
         wantedBy = [ "multi-user.target" ];