{ pkgs, ... }:
{
  environment.systemPackages = [ pkgs.matrix-synapse-tools.rust-synapse-compress-state ];
  systemd.services.compress-matrix-state = {
    serviceConfig.Type = "oneshot";
    path = [
      pkgs.matrix-synapse-tools.rust-synapse-compress-state
    ];
    script = ''
      synapse_auto_compressor -p "host=/run/postgresql port=5432 user=matrix-synapse dbname=matrix-synapse" -n 2000000 -c 10000
    '';
    serviceConfig = {
      User = "matrix-synapse";
    };
  };
  systemd.timers.compress-matrix-state = {
    wantedBy = [ "timers.target" ];
    partOf = [ "compress-matrix-state.service" ];
    timerConfig.OnCalendar = [ "weekly" ];
  };
}
