forked from rarias/jungle
68 lines
1.6 KiB
Nix
68 lines
1.6 KiB
Nix
{ config, lib, ... }:
|
|
{
|
|
services.gitea = {
|
|
enable = true;
|
|
appName = "Gitea in the jungle";
|
|
|
|
settings = {
|
|
server = {
|
|
LANDING_PAGE = "explore";
|
|
};
|
|
service = {
|
|
};
|
|
log.LEVEL = "Warn";
|
|
|
|
mailer = {
|
|
ENABLED = false;
|
|
FROM = "jungle-robot@bsc.es";
|
|
PROTOCOL = "sendmail";
|
|
SENDMAIL_PATH = "/run/wrappers/bin/sendmail";
|
|
SENDMAIL_ARGS = "--";
|
|
};
|
|
};
|
|
|
|
dump = {
|
|
enable = false; # Do not enable NixOS module, use our custom systemd script below
|
|
backupDir = "/vault/gitea";
|
|
};
|
|
};
|
|
|
|
systemd.services.gitea-dump-rotating = let
|
|
cfg = config.services.gitea;
|
|
exe = lib.getExe cfg.package;
|
|
in {
|
|
description = "gitea dump rotation";
|
|
after = [ "gitea.service" ];
|
|
path = [ cfg.package ];
|
|
|
|
environment = {
|
|
USER = cfg.user;
|
|
HOME = cfg.stateDir;
|
|
GITEA_WORK_DIR = cfg.stateDir;
|
|
GITEA_CUSTOM = cfg.customDir;
|
|
};
|
|
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
User = cfg.user;
|
|
WorkingDirectory = cfg.dump.backupDir;
|
|
};
|
|
|
|
script = ''
|
|
name="gitea-dump-$(date +%a).${cfg.dump.type}"
|
|
${exe} dump --type ${cfg.dump.type} --file - >"$name.tmp"
|
|
mv "$name.tmp" "$name"
|
|
'';
|
|
};
|
|
|
|
systemd.timers.gitea-dump-rotating = {
|
|
description = "Update timer for gitea-dump-rotating";
|
|
partOf = [ "gitea-dump-rotating.service" ];
|
|
wantedBy = [ "timers.target" ];
|
|
timerConfig.OnCalendar = config.services.gitea.dump.interval;
|
|
};
|
|
|
|
# Allow gitea user to send mail
|
|
users.users.gitea.extraGroups = [ "mail-robot" ];
|
|
}
|