Compare commits

...

4 Commits

Author SHA1 Message Date
h7x4
470cc451e0
kommode/gitea: fix backup count 2025-09-04 00:02:58 +02:00
h7x4
a803de2b23
kommode/gitea: enable sd_notify, enable hardware watchdog 2025-09-03 23:48:22 +02:00
h7x4
1dc78b6101
kommode/gitea: bindmount repo-archives to /var/cache/gitea 2025-09-03 23:23:16 +02:00
h7x4
54434b7f93
kommode/gitea: only keep 3 backups 2025-09-03 22:46:13 +02:00

View File

@ -1,4 +1,4 @@
{ config, values, lib, unstablePkgs, ... }:
{ config, values, lib, pkgs, unstablePkgs, ... }:
let
cfg = config.services.gitea;
domain = "git.pvv.ntnu.no";
@ -159,8 +159,17 @@ in {
environment.systemPackages = [ cfg.package ];
systemd.services.gitea.serviceConfig.Type = lib.mkForce "notify";
systemd.services.gitea.serviceConfig.WatchdogSec = "60";
systemd.services.gitea.serviceConfig.CPUSchedulingPolicy = "batch";
systemd.services.gitea.serviceConfig.CacheDirectory = "gitea/repo-archive";
systemd.services.gitea.serviceConfig.BindPaths = [
"%C/gitea/repo-archive:${cfg.stateDir}/data/repo-archive"
];
services.nginx.virtualHosts."${domain}" = {
forceSSL = true;
enableACME = true;
@ -184,4 +193,14 @@ in {
};
networking.firewall.allowedTCPPorts = [ sshPort ];
# Only keep n backup files at a time
systemd.services.gitea-dump.postStop = let
cu = prog: "'${lib.getExe' pkgs.coreutils prog}'";
backupCount = 3;
in ''
for file in $(${cu "ls"} -t1 '${cfg.dump.backupDir}' | ${cu "sort"} --reverse | ${cu "tail"} -n+${toString (backupCount + 1)}); do
${cu "rm"} "$file"
done
'';
}