summary refs log tree commit diff
path: root/host/Rory-nginx/services/matrix/synapse/workers/single
diff options
context:
space:
mode:
Diffstat (limited to 'host/Rory-nginx/services/matrix/synapse/workers/single')
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/single/appservice.nix46
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/single/background.nix46
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/single/user-dir.nix46
3 files changed, 48 insertions, 90 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
index a19b076..315a322 100644
--- a/host/Rory-nginx/services/matrix/synapse/workers/single/appservice.nix
+++ b/host/Rory-nginx/services/matrix/synapse/workers/single/appservice.nix
@@ -10,6 +10,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.enableAppserviceWorker {
     services.matrix-synapse = {
@@ -39,28 +42,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; });
         };
@@ -70,21 +62,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}
+          )
         )
       );
     };
diff --git a/host/Rory-nginx/services/matrix/synapse/workers/single/background.nix b/host/Rory-nginx/services/matrix/synapse/workers/single/background.nix
index bfa1793..b667e19 100644
--- a/host/Rory-nginx/services/matrix/synapse/workers/single/background.nix
+++ b/host/Rory-nginx/services/matrix/synapse/workers/single/background.nix
@@ -12,6 +12,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.enableBackgroundWorker {
     services.matrix-synapse = {
@@ -41,28 +44,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; });
         };
@@ -72,21 +64,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}
+          )
         )
       );
     };
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}
+          )
         )
       );
     };