about summary refs log tree commit diff
diff options
context:
space:
mode:
authorIngolf Wagner <contact@ingolf-wagner.de>2019-11-14 16:51:38 +0100
committerLassulus <github@lassul.us>2019-11-19 20:31:30 +0100
commitdcdf4cec3aa33036f4d39a78bbc4b2f8edfc50e5 (patch)
treee443ac5fdce4c6dd703edb9589e59b7f3a6be63d
parentae9846c339f3a11bffad5997b559ba53fd0e23f4 (diff)
downloadnixlib-dcdf4cec3aa33036f4d39a78bbc4b2f8edfc50e5.tar
nixlib-dcdf4cec3aa33036f4d39a78bbc4b2f8edfc50e5.tar.gz
nixlib-dcdf4cec3aa33036f4d39a78bbc4b2f8edfc50e5.tar.bz2
nixlib-dcdf4cec3aa33036f4d39a78bbc4b2f8edfc50e5.tar.lz
nixlib-dcdf4cec3aa33036f4d39a78bbc4b2f8edfc50e5.tar.xz
nixlib-dcdf4cec3aa33036f4d39a78bbc4b2f8edfc50e5.tar.zst
nixlib-dcdf4cec3aa33036f4d39a78bbc4b2f8edfc50e5.zip
nixos/syncthing: add versioning
-rw-r--r--nixos/modules/services/networking/syncthing.nix64
1 files changed, 64 insertions, 0 deletions
diff --git a/nixos/modules/services/networking/syncthing.nix b/nixos/modules/services/networking/syncthing.nix
index 165fd5970cf8..b3f2af5b1794 100644
--- a/nixos/modules/services/networking/syncthing.nix
+++ b/nixos/modules/services/networking/syncthing.nix
@@ -18,6 +18,7 @@ let
     fsWatcherEnabled = folder.watch;
     fsWatcherDelayS = folder.watchDelay;
     ignorePerms = folder.ignorePerms;
+    versioning = folder.versioning;
   }) (filterAttrs (
     _: folder:
     folder.enable
@@ -220,6 +221,69 @@ in {
                 '';
               };
 
+              versioning = mkOption {
+                default = null;
+                description = ''
+                  How to keep changed/deleted files with syncthing.
+                  There are 4 different types of versioning with different parameters.
+                  See https://docs.syncthing.net/users/versioning.html
+                '';
+                example = [
+                  {
+                    versioning = {
+                      type = "simple";
+                      params.keep = "10";
+                    };
+                  }
+                  {
+                    versioning = {
+                      type = "trashcan";
+                      params.cleanoutDays = "1000";
+                    };
+                  }
+                  {
+                    versioning = {
+                      type = "staggered";
+                      params = {
+                        cleanInterval = "3600";
+                        maxAge = "31536000";
+                        versionsPath = "/syncthing/backup";
+                      };
+                    };
+                  }
+                  {
+                    versioning = {
+                      type = "external";
+                      params.versionsPath = pkgs.writers.writeBash "backup" ''
+                        folderpath="$1"
+                        filepath="$2"
+                        rm -rf "$folderpath/$filepath"
+                      '';
+                    };
+                  }
+                ];
+                type = with types; nullOr (submodule {
+                  options = {
+                    type = mkOption {
+                      type = enum [ "external" "simple" "staggered" "trashcan" ];
+                      description = ''
+                        Type of versioning.
+                        See https://docs.syncthing.net/users/versioning.html
+                      '';
+                    };
+                    params = mkOption {
+                      type = attrsOf (either str path);
+                      description = ''
+                        Parameters for versioning. Structure depends on versioning.type.
+                        See https://docs.syncthing.net/users/versioning.html
+                      '';
+                    };
+                  };
+                });
+              };
+
+
+
               rescanInterval = mkOption {
                 type = types.int;
                 default = 3600;