{
  config,
  lib,
  ...
}:
let
  redisEnable = config.machine.redis.enable;
  inherit (config.machine.synapse) enable;
in
with lib;
mkIf (redisEnable && enable) {
  services.redis.servers.matrix-synapse = {
    enable = true;
  };
  systemd.services.matrix-synapse.serviceConfig.SupplementaryGroups = [ "redis-matrix-synapse" ];
  services.matrix-synapse.settings.redis = {
    enabled = true;
    path = config.services.redis.servers.matrix-synapse.unixSocket;
  };
}
