summary refs log tree commit diff
path: root/host/Rory-nginx/services/matrix/synapse.nix
diff options
context:
space:
mode:
Diffstat (limited to 'host/Rory-nginx/services/matrix/synapse.nix')
-rwxr-xr-xhost/Rory-nginx/services/matrix/synapse.nix115
1 files changed, 93 insertions, 22 deletions
diff --git a/host/Rory-nginx/services/matrix/synapse.nix b/host/Rory-nginx/services/matrix/synapse.nix
index 26c61a1..6e0f537 100755
--- a/host/Rory-nginx/services/matrix/synapse.nix
+++ b/host/Rory-nginx/services/matrix/synapse.nix
@@ -1,5 +1,12 @@
 { config, pkgs, lib, ... }:
 
+let
+  federationSenders = lib.range 0 31;
+  federationReceivers = lib.range 10000 10000;
+  initialSyncWorkers = lib.range 10100 10100;
+  syncWorkers = lib.range 10150 10150;
+  streamWriters = lib.range 10200 10200;
+in
 {
   services.matrix-synapse = {
     enable = true;
@@ -51,7 +58,18 @@
           x_forwarded = true;
           resources = [ {
             names = [ "client" "federation" ];
-            compress = true;
+            compress = false;
+          } ];
+        }
+        { 
+          port = 8009;
+          bind_addresses = [ "127.0.0.1" ];
+          type = "http";
+          tls = false;
+          x_forwarded = true;
+          resources = [ {
+            names = [ "replication" ];
+            compress = false;
           } ];
         }
       ];
@@ -147,10 +165,6 @@
         token_timeout = "1y";
       };
 
-      #sentry = {
-      #  dsn = "https://77c8de07855d4e0c90dbcf0945a04f01@sentry.thearcanebrony.net/14";
-      #};
-
       report_stats = false;
 
       user_directory = {
@@ -166,25 +180,69 @@
         "org.matrix.msc3874" = true;
         "org.matrix.msc3912" = true;
       };
+
+
+      redis = {
+        enabled = true;
+        path = "/run/redis-matrix-synapse/redis.sock";
+      };
+
+
+      instance_map = {
+        main = {
+          host = "127.0.0.1";
+          port = 8009;
+        };
+      } // builtins.listToAttrs (map (port: {
+        name = "federation_sender-${toString port}";
+        value = {
+          path = "/run/synapse/federation_sender-${toString port}.sock";
+        };
+      }) federationSenders);
+      #} // builtins.listToAttrs (map (port: {
+      #  name = "federation_receiver-${toString port}";
+      #  value = {
+      #    path = "/run/synapse/federation_receiver-${toString port}.sock";
+      #  };
+      #}) federationReceivers);
+
+      # by type:
+
+      #map to list
+      federation_sender_instances = map (port: "federation_sender-${toString port}") federationSenders;
+
     };
 
-    plugins = with pkgs.matrix-synapse-plugins; [
-      # Alicia - need to port draupnir...
-      #matrix-synapse-mjolnir-antispam
-#      matrix-synapse-pam
-    ];
-#    extraConfigFiles = [
-#        (pkgs.writeTextFile {
-#          name = "matrix-synapse-extra-config.yml";
-#          text = ''
-#            modules:
-#              - module: "pam_auth_provider.PAMAuthProvider"
-#                config:
-#                  create_users: true
-#                  skip_user_check: false
-#          '';
-#        })
-#      ];
+    ## TODO: INVESTIGATE
+    # worker_listeners:
+    # - type: metrics
+    #   bind_address: ''
+    #   port: 9101
+
+    workers = 
+    #builtins.listToAttrs (map (port: {
+    #  name = "federation_receiver-${toString port}";
+    #  value = {
+    #    worker_app = "synapse.app.generic_worker";
+    #    worker_listeners = [
+    #      { 
+    #        port = port;
+    #        type = "http";
+    #        resources = [ {
+    #          names = [ "federation" ];
+    #          compress = false;
+    #        } ];
+    #      }
+    #    ];
+    #  };
+    #}) federationReceivers)
+    builtins.listToAttrs (map (port: {
+      name = "federation_sender-${toString port}";
+      value = {
+        worker_app = "synapse.app.generic_worker";
+        worker_listeners = [ ];
+      };
+    }) federationSenders);
   };
 
     systemd.services.matrix-synapse-reg-token = {
@@ -208,5 +266,18 @@
       };
     };
 
+
+  services.redis = {
+    package = pkgs.keydb;
+    servers.matrix-synapse = {
+      enable = true;
+      user = "matrix-synapse";
+    };
+  };
+  
+  systemd.tmpfiles.rules = [
+    "D /run/redis-matrix-synapse 0755 matrix-synapse matrix-synapse"
+  ];
+
 }