summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorElis Hirwing <elis@hirwing.se>2018-05-15 21:17:51 +0200
committerElis Hirwing <elis@hirwing.se>2018-05-20 10:49:24 +0200
commitce42182d13db1721d49709779ea6b3f8a93280fd (patch)
tree3f7c30d6abf4aaa6e97087a49c11286a393f6fb5 /nixos
parente166aee826f7f58b53a583837e2399811ff61eaa (diff)
downloadnixlib-ce42182d13db1721d49709779ea6b3f8a93280fd.tar
nixlib-ce42182d13db1721d49709779ea6b3f8a93280fd.tar.gz
nixlib-ce42182d13db1721d49709779ea6b3f8a93280fd.tar.bz2
nixlib-ce42182d13db1721d49709779ea6b3f8a93280fd.tar.lz
nixlib-ce42182d13db1721d49709779ea6b3f8a93280fd.tar.xz
nixlib-ce42182d13db1721d49709779ea6b3f8a93280fd.tar.zst
nixlib-ce42182d13db1721d49709779ea6b3f8a93280fd.zip
nixos/gitea: Add options to enable a timer with optional interval
This will run gitea dump and create a backup file for gitea every so
often as the interval is defined to do.
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/misc/gitea.nix51
1 files changed, 51 insertions, 0 deletions
diff --git a/nixos/modules/services/misc/gitea.nix b/nixos/modules/services/misc/gitea.nix
index 9f7e1ea8c49d..2d0f66de037d 100644
--- a/nixos/modules/services/misc/gitea.nix
+++ b/nixos/modules/services/misc/gitea.nix
@@ -164,6 +164,30 @@ in
         };
       };
 
+      dump = {
+        enable = mkOption {
+          type = types.bool;
+          default = false;
+          description = ''
+            Enable a timer that runs gitea dump to generate backup-files of the
+            current gitea database and repositories.
+          '';
+        };
+
+        interval = mkOption {
+          type = types.str;
+          default = "04:31";
+          example = "hourly";
+          description = ''
+            Run a gitea dump at this interval. Runs by default at 04:31 every day.
+
+            The format is described in
+            <citerefentry><refentrytitle>systemd.time</refentrytitle>
+            <manvolnum>7</manvolnum></citerefentry>.
+          '';
+        };
+      };
+
       appName = mkOption {
         type = types.str;
         default = "gitea: Gitea Service";
@@ -326,5 +350,32 @@ in
         name = "gitea-database-password";
         text = cfg.database.password;
       })));
+
+    systemd.services.gitea-dump = {
+       description = "gitea dump";
+       after = [ "gitea.service" ];
+       wantedBy = [ "default.target" ];
+       path = [ gitea.bin ];
+
+       environment = {
+         USER = cfg.user;
+         HOME = cfg.stateDir;
+         GITEA_WORK_DIR = cfg.stateDir;
+       };
+
+       serviceConfig = {
+         Type = "oneshot";
+         User = cfg.user;
+         ExecStart = "${gitea.bin}/bin/gitea dump";
+         WorkingDirectory = cfg.stateDir;
+       };
+    };
+
+    systemd.timers.gitea-dump = {
+      description = "Update timer for gitea-dump";
+      partOf = [ "gitea-dump.service" ];
+      wantedBy = [ "timers.target" ];
+      timerConfig.OnCalendar = cfg.dump.interval;
+    };
   };
 }