X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=modules%2Fwebapps%2Fmastodon.nix;h=68531cf3dbad21201ffb5d59416cd5cd78c9fb13;hb=72300eb8116c960935a462564d96db6fac355bca;hp=6255de91a708be894751ce298c4e67391abbaac5;hpb=24fd1fe6c62b7a9fc347794fde043285da272f5c;p=perso%2FImmae%2FConfig%2FNix%2FNUR.git diff --git a/modules/webapps/mastodon.nix b/modules/webapps/mastodon.nix index 6255de91..68531cf3 100644 --- a/modules/webapps/mastodon.nix +++ b/modules/webapps/mastodon.nix @@ -27,7 +27,7 @@ in ''; }; socketsPrefix = lib.mkOption { - type = lib.types.string; + type = lib.types.str; default = "live"; description = '' The prefix to use for Mastodon sockets. @@ -171,6 +171,9 @@ in exec ./bin/bundle exec puma -C config/puma.rb ''; + postStart = '' + exec ./bin/tootctl cache clear + ''; serviceConfig = { User = cfg.user; EnvironmentFile = cfg.configFile; @@ -187,6 +190,36 @@ in unitConfig.RequiresMountsFor = cfg.dataDir; }; + systemd.services.mastodon-cleanup = { + description = "Cleanup mastodon"; + startAt = "daily"; + restartIfChanged = false; + + environment.RAILS_ENV = "production"; + environment.BUNDLE_PATH = "${cfg.workdir.gems}/${cfg.workdir.gems.ruby.gemPath}"; + environment.BUNDLE_GEMFILE = "${cfg.workdir.gems.confFiles}/Gemfile"; + environment.SOCKET = cfg.sockets.rails; + + path = [ cfg.workdir.gems cfg.workdir.gems.ruby pkgs.file ]; + + script = '' + exec ./bin/tootctl media remove --days 30 + ''; + + serviceConfig = { + User = cfg.user; + EnvironmentFile = cfg.configFile; + PrivateTmp = true; + Type = "oneshot"; + WorkingDirectory = cfg.workdir; + StateDirectory = cfg.systemdStateDirectory; + RuntimeDirectory = cfg.systemdRuntimeDirectory; + RuntimeDirectoryPreserve = "yes"; + }; + + unitConfig.RequiresMountsFor = cfg.dataDir; + }; + systemd.services.mastodon-sidekiq = { description = "Mastodon Sidekiq"; wantedBy = [ "multi-user.target" ];