summary refs log tree commit diff
path: root/host/Rory-nginx/services/matrix/synapse/workers/single/user-dir.nix
diff options
context:
space:
mode:
Diffstat (limited to 'host/Rory-nginx/services/matrix/synapse/workers/single/user-dir.nix')
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/single/user-dir.nix46
1 files changed, 16 insertions, 30 deletions
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
index 56dbd5f..89c6aa4 100644
--- a/host/Rory-nginx/services/matrix/synapse/workers/single/user-dir.nix
+++ b/host/Rory-nginx/services/matrix/synapse/workers/single/user-dir.nix
@@ -15,6 +15,9 @@ let
     media = [ ];
   };
 in
+let
+  enabledResources = lib.optionals (lib.length workerRoutes.client > 0) [ "client" ] ++ lib.optionals (lib.length workerRoutes.federation > 0) [ "federation" ] ++ lib.optionals (lib.length workerRoutes.media > 0) [ "media" ];
+in
 {
   config = lib.mkIf cfg.enableUserDirWorker {
     services.matrix-synapse = {
@@ -44,28 +47,17 @@ in
                 ];
               }
             ]
-            ++ lib.optional (lib.length workerRoutes.client > 0) {
+            ++ lib.map (type: {
               type = "http";
-              path = "/run/matrix-synapse/${workerName}-client.sock";
+              path = "/run/matrix-synapse/${workerName}-${type}.sock";
               mode = "666";
               resources = [
                 {
-                  names = [ "client" ];
+                  names = [ type ];
                   compress = false;
                 }
               ];
-            }
-            ++ lib.optional (lib.length workerRoutes.federation > 0) {
-              type = "http";
-              path = "/run/matrix-synapse/${workerName}-federation.sock";
-              mode = "666";
-              resources = [
-                {
-                  names = [ "federation" ];
-                  compress = false;
-                }
-              ];
-            };
+            }) enabledResources;
 
           database = (import ../../db.nix { inherit workerName dbGroup; });
         };
@@ -75,21 +67,15 @@ in
     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}
-            )
+          lib.forEach enabledResources (
+            type:
+            lib.map (route: {
+              name = route;
+              value = {
+                proxyPass = "http://unix:/run/matrix-synapse/${workerName}-${type}.sock";
+              };
+            }) workerRoutes.${type}
+          )
         )
       );
     };