{ config, pkgs, lib, ... }: let cfg = config.services.matrix-synapse; in { services.matrix-synapse = lib.mkIf cfg.enableBackgroundWorker { settings = { instance_map = { appservice = { path = "/run/matrix-synapse/background.sock"; }; }; run_background_tasks_on = "background"; }; workers = { appservice = { worker_app = "synapse.app.generic_worker"; worker_listeners = [ { type = "http"; path = "/run/matrix-synapse/background.sock"; resources = [ { names = [ "replication" ]; compress = false; } ]; } ]; }; }; }; }