38 lines
1.2 KiB
Nix
38 lines
1.2 KiB
Nix
{ config, pkgs, ... }:
|
|
|
|
{
|
|
# delete empty directories
|
|
# - https://github.com/element-hq/synapse/issues/7690
|
|
# - https://github.com/matrix-org/synapse/issues/7690
|
|
systemd.services.matrix-synapse.preStart =
|
|
''${pkgs.findutils}/bin/find ${config.services.matrix-synapse.dataDir}/media_store -empty -type d -delete'';
|
|
|
|
systemd.timers."matrix-synapse-housecleaning-empty-dirs" = {
|
|
wantedBy = [ "timers.target" ];
|
|
timerConfig = {
|
|
OnCalendar = "Mon *-*-* 04:00:00";
|
|
Unit = config.systemd.services.matrix-synapse.name;
|
|
};
|
|
};
|
|
|
|
# vacuum database
|
|
systemd.services."matrix-synapse-psql-vacuum" = let
|
|
psqlUser = config.systemd.services.postgresql.serviceConfig.user;
|
|
dbName = config.services.matrix-synapse.settings.database.args.database;
|
|
in {
|
|
serviceConfig = {
|
|
User = psqlUser;
|
|
ExecStart = pkgs.writeScript "matrix-synapse-psql-vacuum.sh" ''
|
|
${config.services.postgresql.package}/bin/psql -d ${dbName} -c "vacuum full"
|
|
'';
|
|
};
|
|
};
|
|
|
|
systemd.timers."matrix-synapse-housecleaning-vacuum-db" = {
|
|
wantedBy = [ "timers.target" ];
|
|
timerConfig = {
|
|
OnCalendar = "Mon *-*-* 04:00:00";
|
|
Unit = config.systemd.services.matrix-synapse-psql-vacuum.name;
|
|
};
|
|
};
|
|
}
|