summary refs log tree commit diff
path: root/host/Rory-nginx/services/matrix/synapse/workers/federation-inbound.nix
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2024-08-04 05:08:05 +0200
committerRory& <root@rory.gay>2024-08-04 05:08:05 +0200
commit4402873891edace4b678af537236ff1d81bba585 (patch)
tree343f32b070b98eaba7e11ab77bd27ce98a464bc7 /host/Rory-nginx/services/matrix/synapse/workers/federation-inbound.nix
parentUpdate flake lock (diff)
downloadRory-Open-Architecture-4402873891edace4b678af537236ff1d81bba585.tar.xz
Server config cleanup
Diffstat (limited to 'host/Rory-nginx/services/matrix/synapse/workers/federation-inbound.nix')
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/federation-inbound.nix32
1 files changed, 13 insertions, 19 deletions
diff --git a/host/Rory-nginx/services/matrix/synapse/workers/federation-inbound.nix b/host/Rory-nginx/services/matrix/synapse/workers/federation-inbound.nix
index 9853601..2e3574f 100644
--- a/host/Rory-nginx/services/matrix/synapse/workers/federation-inbound.nix
+++ b/host/Rory-nginx/services/matrix/synapse/workers/federation-inbound.nix
@@ -1,16 +1,10 @@
-{
-  config,
-  pkgs,
-  lib,
-  ...
-}:
+{ config, lib, ... }:
 
 let
   cfg = config.services.matrix-synapse;
   workers = lib.range 0 (cfg.federationReaders - 1);
-  routes = [
-    "~ /_matrix/federation/(v1|v2)/send/"
-  ];
+  workerName = "federation_inbound";
+  workerRoutes = [ "~ /_matrix/federation/(v1|v2)/send/" ];
 in
 {
   config = lib.mkIf (cfg.federationInboundWorkers > 0) {
@@ -18,9 +12,9 @@ in
       settings = {
         instance_map = lib.listToAttrs (
           lib.map (index: {
-            name = "federation_inbound-${toString index}";
+            name = "${workerName}-${toString index}";
             value = {
-              path = "/run/matrix-synapse/federation_inbound-${toString index}.sock";
+              path = "/run/matrix-synapse/${workerName}-${toString index}.sock";
             };
           }) workers
         );
@@ -28,13 +22,13 @@ in
 
       workers = lib.listToAttrs (
         lib.map (index: {
-          name = "federation_inbound-${toString index}";
+          name = "${workerName}-${toString index}";
           value = {
             worker_app = "synapse.app.generic_worker";
             worker_listeners = [
               {
                 type = "http";
-                path = "/run/matrix-synapse/federation_inbound-${toString index}.sock";
+                path = "/run/matrix-synapse/${workerName}-${toString index}.sock";
                 resources = [
                   {
                     names = [ "replication" ];
@@ -44,7 +38,7 @@ in
               }
               {
                 type = "http";
-                path = "/run/matrix-synapse/federation_inbound-federation-${toString index}.sock";
+                path = "/run/matrix-synapse/${workerName}-federation-${toString index}.sock";
                 mode = "666";
                 resources = [
                   {
@@ -56,7 +50,7 @@ in
             ];
             database = (
               import ../db.nix {
-                workerName = "federation_inbound-${toString index}";
+                workerName = "${workerName}-${toString index}";
                 dbGroup = "medium";
               }
             );
@@ -65,14 +59,14 @@ in
       );
     };
 
-    services.nginx.upstreams."federation_inbound" = {
+    services.nginx.upstreams."${workerName}" = {
       extraConfig = ''
         keepalive 32;
         ip_hash;
       '';
       servers = lib.listToAttrs (
         lib.map (index: {
-          name = "unix:/run/matrix-synapse/federation_inbound-federation-${toString index}.sock";
+          name = "unix:/run/matrix-synapse/${workerName}-federation-${toString index}.sock";
           value = {
             max_fails = 0;
           };
@@ -84,9 +78,9 @@ in
       lib.map (route: {
         name = route;
         value = {
-          proxyPass = "http://federation_inbound";
+          proxyPass = "http://${workerName}";
         };
-      }) routes
+      }) workerRoutes
     );
   };
 }