git.iko.soy/typeable/nixpkgs
on master help sign in
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.

commitce42182d13db1721d49709779ea6b3f8a93280fd authorElis Hirwing <elis@hirwing.se> dateTue 15 May 2018, 21:17 (9 years ago) parente166aee
1 file changed+51
nixos/modules/services/misc/gitea.nix+51
nixos/modules/services/misc/gitea.nix+51
@@ -164,6 +164,30 @@ in
164164 };
165165 };
166166
167+ dump = {
168+ enable = mkOption {
169+ type = types.bool;
170+ default = false;
171+ description = ''
172+ Enable a timer that runs gitea dump to generate backup-files of the
173+ current gitea database and repositories.
174+ '';
175+ };
176+
177+ interval = mkOption {
178+ type = types.str;
179+ default = "04:31";
180+ example = "hourly";
181+ description = ''
182+ Run a gitea dump at this interval. Runs by default at 04:31 every day.
183+
184+ The format is described in
185+ <citerefentry><refentrytitle>systemd.time</refentrytitle>
186+ <manvolnum>7</manvolnum></citerefentry>.
187+ '';
188+ };
189+ };
190+
167191 appName = mkOption {
168192 type = types.str;
169193 default = "gitea: Gitea Service";
@@ -326,5 +350,32 @@ in
326350 name = "gitea-database-password";
327351 text = cfg.database.password;
328352 })));
353+
354+ systemd.services.gitea-dump = {
355+ description = "gitea dump";
356+ after = [ "gitea.service" ];
357+ wantedBy = [ "default.target" ];
358+ path = [ gitea.bin ];
359+
360+ environment = {
361+ USER = cfg.user;
362+ HOME = cfg.stateDir;
363+ GITEA_WORK_DIR = cfg.stateDir;
364+ };
365+
366+ serviceConfig = {
367+ Type = "oneshot";
368+ User = cfg.user;
369+ ExecStart = "${gitea.bin}/bin/gitea dump";
370+ WorkingDirectory = cfg.stateDir;
371+ };
372+ };
373+
374+ systemd.timers.gitea-dump = {
375+ description = "Update timer for gitea-dump";
376+ partOf = [ "gitea-dump.service" ];
377+ wantedBy = [ "timers.target" ];
378+ timerConfig.OnCalendar = cfg.dump.interval;
379+ };
329380 };
330381}