diff options
| author | lassulus <git@lassul.us> | 2025-10-21 19:28:51 +0200 |
|---|---|---|
| committer | lassulus <git@lassul.us> | 2025-10-21 19:34:18 +0200 |
| commit | 4832701fadccdf5faceb96cecf274b9d57f3196b (patch) | |
| tree | 58aa6d347bfc7c5714006d5b1a22a11a73d5749b | |
| parent | fc32e4609140fffa1312a4ca1aeea550b7467448 (diff) | |
mastodon: run gc daily
| -rw-r--r-- | krebs/2configs/mastodon.nix | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/krebs/2configs/mastodon.nix b/krebs/2configs/mastodon.nix index 723e2c385..3c7205167 100644 --- a/krebs/2configs/mastodon.nix +++ b/krebs/2configs/mastodon.nix @@ -1,4 +1,14 @@ { config, lib, pkgs, ... }: +let + mastodon-clear-cache = pkgs.writers.writeDashBin "mastodon-clear-cache" '' + /run/current-system/sw/bin/mastodon-tootctl media remove --prune-profiles --days=14 --concurrency=30 + /run/current-system/sw/bin/mastodon-tootctl media remove-orphans + /run/current-system/sw/bin/mastodon-tootctl preview_cards remove --days=14 + /run/current-system/sw/bin/mastodon-tootctl accounts prune + /run/current-system/sw/bin/mastodon-tootctl statuses remove --days 4 + /run/current-system/sw/bin/mastodon-tootctl media remove --days 4 + ''; +in { services.postgresql = { enable = true; @@ -25,15 +35,20 @@ 443 ]; + systemd.services.mastodon-clear-cache = { + description = "Mastodon Clear Cache"; + wantedBy = [ "timers.target" ]; + startAt = "daily"; + serviceConfig = { + Type = "oneshot"; + ExecStart = "${mastodon-clear-cache}/bin/mastodon-clear-cache"; + User = "mastodon"; + WorkingDirectory = "/var/lib/mastodon"; + }; + }; + environment.systemPackages = [ - (pkgs.writers.writeDashBin "mastodon-clear-cache" '' - mastodon-tootctl media remove --prune-profiles --days=14 --concurrency=30 - mastodon-tootctl media remove-orphans - mastodon-tootctl preview_cards remove --days=14 - mastodon-tootctl accounts prune - mastodon-tootctl statuses remove --days 4 - mastodon-tootctl media remove --days 4 - '') + mastodon-clear-cache (pkgs.writers.writeDashBin "create-mastodon-user" '' set -efu nick=$1 |
