add mastodon cleanup systemd timer
This commit is contained in:
parent
71ea216d71
commit
a0e9336337
1 changed files with 30 additions and 1 deletions
|
@ -18,7 +18,7 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
vault-secrets.secrets.mastodon = {
|
vault-secrets.secrets.mastodon = {
|
||||||
services = [ "mastodon-init-dirs" "mastodon" ];
|
services = [ "mastodon-init-dirs" "mastodon" "mastodon-media-prune" ];
|
||||||
user = cfg.user;
|
user = cfg.user;
|
||||||
group = cfg.group;
|
group = cfg.group;
|
||||||
};
|
};
|
||||||
|
@ -92,6 +92,35 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# https://github.com/NixOS/nixpkgs/issues/116418#issuecomment-799517120
|
||||||
|
systemd.services.mastodon-media-prune =
|
||||||
|
let
|
||||||
|
cfg = config.services.mastodon;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
description = "Mastodon media prune";
|
||||||
|
environment = lib.filterAttrs (n: _: n != "PATH") config.systemd.services.mastodon-web.environment;
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
# Remove remote media attachments older than one month.
|
||||||
|
ExecStart = "${cfg.package}/bin/tootctl media remove --days=30";
|
||||||
|
User = cfg.user;
|
||||||
|
Group = cfg.group;
|
||||||
|
EnvironmentFile = "/var/lib/mastodon/.secrets_env";
|
||||||
|
PrivateTmp = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.timers.mastodon-media-prune = {
|
||||||
|
description = "Mastodon media prune";
|
||||||
|
wantedBy = [ "timers.target" ];
|
||||||
|
timerConfig = {
|
||||||
|
OnCalendar = "*-*-* 00:00:00"; # every day
|
||||||
|
Unit = "mastodon-media-prune.service";
|
||||||
|
AccuracySec = "60s";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
networking.firewall =
|
networking.firewall =
|
||||||
let cfg = config.services.mastodon;
|
let cfg = config.services.mastodon;
|
||||||
in { allowedTCPPorts = [ cfg.streamingPort cfg.webPort ]; };
|
in { allowedTCPPorts = [ cfg.streamingPort cfg.webPort ]; };
|
||||||
|
|
Loading…
Reference in a new issue