summary refs log tree commit diff
path: root/host/Rory-nginx/services/matrix/synapse/workers/sync.nix
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2024-08-16 14:39:37 +0200
committerRory& <root@rory.gay>2024-08-16 14:39:37 +0200
commit4a60627f7f5f4e6a64a93635bd0df2c7f6b2cd17 (patch)
tree8159e19ce6762e40f538a9a40f11b05eb4da7d09 /host/Rory-nginx/services/matrix/synapse/workers/sync.nix
parentUnify single workers (diff)
downloadRory-Open-Architecture-4a60627f7f5f4e6a64a93635bd0df2c7f6b2cd17.tar.xz
Start reworking other workers
Diffstat (limited to '')
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/sync.nix47
1 files changed, 31 insertions, 16 deletions
diff --git a/host/Rory-nginx/services/matrix/synapse/workers/sync.nix b/host/Rory-nginx/services/matrix/synapse/workers/sync.nix
index 2655ff3..645e550 100644
--- a/host/Rory-nginx/services/matrix/synapse/workers/sync.nix
+++ b/host/Rory-nginx/services/matrix/synapse/workers/sync.nix
@@ -3,16 +3,18 @@
 let
   cfg = config.services.matrix-synapse;
   dbGroup = "small";
-  hasClientResource = false;
-  hasFederationResource = false;
   workers = lib.range 0 (cfg.syncWorkers - 1);
   workerName = "sync";
-  workerRoutes = [
-    "~ ^/_matrix/client/(v2_alpha|r0|v3)/sync$"
-    "~ ^/_matrix/client/(api/v1|v2_alpha|r0|v3)/events$"
-    "~ ^/_matrix/client/(api/v1|r0|v3)/initialSync$"
-    "~ ^/_matrix/client/(api/v1|r0|v3)/rooms/[^/]+/initialSync$"
-  ];
+  workerRoutes = {
+    client = [
+      "~ ^/_matrix/client/(v2_alpha|r0|v3)/sync$"
+      "~ ^/_matrix/client/(api/v1|v2_alpha|r0|v3)/events$"
+      "~ ^/_matrix/client/(api/v1|r0|v3)/initialSync$"
+      "~ ^/_matrix/client/(api/v1|r0|v3)/rooms/[^/]+/initialSync$"
+    ];
+    federation = [ ];
+    media = [ ];
+  };
 in
 {
   config = lib.mkIf (cfg.syncWorkers > 0) {
@@ -81,13 +83,26 @@ in
       );
     };
 
-    services.nginx.virtualHosts."${cfg.nginxVirtualHostName}".locations = lib.listToAttrs (
-      lib.map (route: {
-        name = route;
-        value = {
-          proxyPass = "http://${workerName}";
-        };
-      }) workerRoutes
-    );
+    services.nginx = {
+      virtualHosts."${cfg.nginxVirtualHostName}".locations = lib.listToAttrs (
+        lib.flatten (
+          lib.forEach
+            [
+              "client"
+              "federation"
+              "media"
+            ]
+            (
+              type:
+              lib.map (route: {
+                name = route;
+                value = {
+                  proxyPass = "http://unix:/run/matrix-synapse/${workerName}-${type}.sock";
+                };
+              }) workerRoutes.${type}
+            )
+        )
+      );
+    };
   };
 }