about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorIngolf Wagner <contact@ingolf-wagner.de>2019-10-29 21:04:26 +0100
committerLassulus <github@lassul.us>2019-11-12 19:29:18 +0100
commit69493cc67a7be9b7913ec5a69339995956fabc63 (patch)
tree44357cceed042a3e92ba659e39105b4e0ba8f807 /nixos
parent41a1d984634a70d29d498355fbb270a60d6f99b3 (diff)
downloadnixlib-69493cc67a7be9b7913ec5a69339995956fabc63.tar
nixlib-69493cc67a7be9b7913ec5a69339995956fabc63.tar.gz
nixlib-69493cc67a7be9b7913ec5a69339995956fabc63.tar.bz2
nixlib-69493cc67a7be9b7913ec5a69339995956fabc63.tar.lz
nixlib-69493cc67a7be9b7913ec5a69339995956fabc63.tar.xz
nixlib-69493cc67a7be9b7913ec5a69339995956fabc63.tar.zst
nixlib-69493cc67a7be9b7913ec5a69339995956fabc63.zip
nixos/syncthing: simple versioning
add simple versioning. I did not add the other versioning
types because I did not understand most of them.
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/networking/syncthing.nix54
1 files changed, 54 insertions, 0 deletions
diff --git a/nixos/modules/services/networking/syncthing.nix b/nixos/modules/services/networking/syncthing.nix
index 165fd5970cf8..96b90021a810 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,59 @@ 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#simple-file-versioning
+                '';
+                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" ];
+                    };
+                    params = mkOption {
+                      type = attrsOf (either str path);
+                    };
+                  };
+                });
+              };
+
               rescanInterval = mkOption {
                 type = types.int;
                 default = 3600;