diff options
Diffstat (limited to 'host/Rory-nginx/services/matrix/synapse/workers/single')
3 files changed, 241 insertions, 0 deletions
diff --git a/host/Rory-nginx/services/matrix/synapse/workers/single/appservice.nix b/host/Rory-nginx/services/matrix/synapse/workers/single/appservice.nix new file mode 100644 index 0000000..ace3bf6 --- /dev/null +++ b/host/Rory-nginx/services/matrix/synapse/workers/single/appservice.nix @@ -0,0 +1,79 @@ +{ config, lib, ... }: + +let + cfg = config.services.matrix-synapse; + dbGroup = "small"; + hasClientResource = false; + hasFederationResource = false; + workerName = "appservice"; + workerRoutes = [ ]; +in +{ + config = lib.mkIf cfg.enableAppserviceWorker { + services.matrix-synapse = { + settings = { + instance_map = { + ${workerName} = { + path = "/run/matrix-synapse/${workerName}.sock"; + }; + }; + + notify_appservices_from_worker = workerName; + }; + + workers = { + ${workerName} = { + worker_app = "synapse.app.generic_worker"; + worker_listeners = + [ + { + type = "http"; + path = "/run/matrix-synapse/${workerName}.sock"; + resources = [ + { + names = [ "replication" ]; + compress = false; + } + ]; + } + ] + ++ lib.optional hasClientResource { + type = "http"; + path = "/run/matrix-synapse/${workerName}-client.sock"; + mode = "666"; + resources = [ + { + names = [ "client" ]; + compress = false; + } + ]; + } + ++ lib.optional hasFederationResource { + type = "http"; + path = "/run/matrix-synapse/${workerName}-federation.sock"; + mode = "666"; + resources = [ + { + names = [ "federation" ]; + compress = false; + } + ]; + }; + + database = (import ../../db.nix { inherit workerName dbGroup; }); + }; + }; + }; + + services.nginx = { + virtualHosts."${cfg.nginxVirtualHostName}".locations = lib.listToAttrs ( + lib.map (route: { + name = route; + value = { + proxyPass = "http://${workerName}"; + }; + }) workerRoutes + ); + }; + }; +} diff --git a/host/Rory-nginx/services/matrix/synapse/workers/single/background.nix b/host/Rory-nginx/services/matrix/synapse/workers/single/background.nix new file mode 100644 index 0000000..acc423d --- /dev/null +++ b/host/Rory-nginx/services/matrix/synapse/workers/single/background.nix @@ -0,0 +1,79 @@ +{ config, lib, ... }: + +let + cfg = config.services.matrix-synapse; + dbGroup = "small"; + hasClientResource = false; + hasFederationResource = false; + workerName = "background"; + workerRoutes = [ ]; +in +{ + config = lib.mkIf cfg.enableBackgroundWorker { + services.matrix-synapse = { + settings = { + instance_map = { + ${workerName} = { + path = "/run/matrix-synapse/${workerName}.sock"; + }; + }; + + run_background_tasks_on = workerName; + }; + + workers = { + ${workerName} = { + worker_app = "synapse.app.generic_worker"; + worker_listeners = + [ + { + type = "http"; + path = "/run/matrix-synapse/${workerName}.sock"; + resources = [ + { + names = [ "replication" ]; + compress = false; + } + ]; + } + ] + ++ lib.optional hasClientResource { + type = "http"; + path = "/run/matrix-synapse/${workerName}-client.sock"; + mode = "666"; + resources = [ + { + names = [ "client" ]; + compress = false; + } + ]; + } + ++ lib.optional hasFederationResource { + type = "http"; + path = "/run/matrix-synapse/${workerName}-federation.sock"; + mode = "666"; + resources = [ + { + names = [ "federation" ]; + compress = false; + } + ]; + }; + + database = (import ../../db.nix { inherit workerName dbGroup; }); + }; + }; + }; + + services.nginx = { + virtualHosts."${cfg.nginxVirtualHostName}".locations = lib.listToAttrs ( + lib.map (route: { + name = route; + value = { + proxyPass = "http://${workerName}"; + }; + }) workerRoutes + ); + }; + }; +} diff --git a/host/Rory-nginx/services/matrix/synapse/workers/single/user-dir.nix b/host/Rory-nginx/services/matrix/synapse/workers/single/user-dir.nix new file mode 100644 index 0000000..0253438 --- /dev/null +++ b/host/Rory-nginx/services/matrix/synapse/workers/single/user-dir.nix @@ -0,0 +1,83 @@ +{ config, lib, ... }: + +let + cfg = config.services.matrix-synapse; + dbGroup = "solo"; + hasClientResource = true; + hasFederationResource = false; + workerName = "user_dir"; + workerRoutes = [ + "~ ^/_matrix/client/(api/v1|r0|v3|unstable)/user_directory/search$" + "~ ^/_matrix/client/v3/profile/.*/(displayname|avatar_url)$" + "~ ^/_matrix/client/v3/profile/.*$" + ]; +in +{ + config = lib.mkIf cfg.enableUserDirWorker { + services.matrix-synapse = { + settings = { + instance_map = { + ${workerName} = { + path = "/run/matrix-synapse/${workerName}.sock"; + }; + }; + + update_user_directory_from_worker = workerName; + }; + + workers = { + ${workerName} = { + worker_app = "synapse.app.generic_worker"; + worker_listeners = + [ + { + type = "http"; + path = "/run/matrix-synapse/${workerName}.sock"; + resources = [ + { + names = [ "replication" ]; + compress = false; + } + ]; + } + ] + ++ lib.optional hasClientResource { + type = "http"; + path = "/run/matrix-synapse/${workerName}-client.sock"; + mode = "666"; + resources = [ + { + names = [ "client" ]; + compress = false; + } + ]; + } + ++ lib.optional hasFederationResource { + type = "http"; + path = "/run/matrix-synapse/${workerName}-federation.sock"; + mode = "666"; + resources = [ + { + names = [ "federation" ]; + compress = false; + } + ]; + }; + + database = (import ../../db.nix { inherit workerName dbGroup; }); + }; + }; + }; + + services.nginx = { + virtualHosts."${cfg.nginxVirtualHostName}".locations = lib.listToAttrs ( + lib.map (route: { + name = route; + value = { + proxyPass = "http://${workerName}"; + }; + }) workerRoutes + ); + }; + }; +} |