summary refs log tree commit diff
path: root/host/Rory-nginx/services/matrix
diff options
context:
space:
mode:
Diffstat (limited to 'host/Rory-nginx/services/matrix')
-rwxr-xr-xhost/Rory-nginx/services/matrix/coturn.nix8
-rwxr-xr-xhost/Rory-nginx/services/matrix/draupnir.nix18
-rwxr-xr-xhost/Rory-nginx/services/matrix/grapevine.nix12
-rwxr-xr-xhost/Rory-nginx/services/matrix/matrix-appservice-discord.nix12
-rwxr-xr-xhost/Rory-nginx/services/matrix/matrix-media-gate.nix9
-rwxr-xr-xhost/Rory-nginx/services/matrix/root.nix28
-rw-r--r--host/Rory-nginx/services/matrix/sliding-sync.nix18
-rwxr-xr-xhost/Rory-nginx/services/matrix/synapse/_synapse.monolith.nix96
-rw-r--r--host/Rory-nginx/services/matrix/synapse/caches.nix16
-rw-r--r--host/Rory-nginx/services/matrix/synapse/db.nix35
-rw-r--r--host/Rory-nginx/services/matrix/synapse/ratelimits.nix2
-rwxr-xr-xhost/Rory-nginx/services/matrix/synapse/synapse-main.nix75
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/appservice.nix13
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/background.nix13
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/federation-sender.nix49
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/module.nix91
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/pusher.nix61
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/stream-writers/__OLD__module.nix113
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/stream-writers/event-stream-writer.nix62
19 files changed, 431 insertions, 300 deletions
diff --git a/host/Rory-nginx/services/matrix/coturn.nix b/host/Rory-nginx/services/matrix/coturn.nix
index 427721a..1fed755 100755
--- a/host/Rory-nginx/services/matrix/coturn.nix
+++ b/host/Rory-nginx/services/matrix/coturn.nix
@@ -1,4 +1,9 @@
-{ config, pkgs, lib, ... }:
+{
+  config,
+  pkgs,
+  lib,
+  ...
+}:
 
 {
   # coturn (WebRTC)
@@ -50,4 +55,3 @@
   #};
 
 }
-
diff --git a/host/Rory-nginx/services/matrix/draupnir.nix b/host/Rory-nginx/services/matrix/draupnir.nix
index 65c5a21..f2a8357 100755
--- a/host/Rory-nginx/services/matrix/draupnir.nix
+++ b/host/Rory-nginx/services/matrix/draupnir.nix
@@ -1,10 +1,15 @@
-{ config, pkgs, lib, ... }:
+{
+  config,
+  pkgs,
+  lib,
+  ...
+}:
 
 {
   # Alicia - doesnt work yet... until in nixpkgs...
   services.draupnir = {
     enable = true;
-    
+
     pantalaimon = {
       enable = true;
       username = "draupnir";
@@ -48,10 +53,9 @@
     };
   };
 
-#  services.pantalaimon-headless.instances.draupnir = {
-#    homeserver = "http://localhost:8008";
-#    ssl = false;
-#  };
+  #  services.pantalaimon-headless.instances.draupnir = {
+  #    homeserver = "http://localhost:8008";
+  #    ssl = false;
+  #  };
 
 }
-
diff --git a/host/Rory-nginx/services/matrix/grapevine.nix b/host/Rory-nginx/services/matrix/grapevine.nix
index 700c4bb..1cb2e19 100755
--- a/host/Rory-nginx/services/matrix/grapevine.nix
+++ b/host/Rory-nginx/services/matrix/grapevine.nix
@@ -1,4 +1,9 @@
-{ config, pkgs, lib, ... }:
+{
+  config,
+  pkgs,
+  lib,
+  ...
+}:
 
 {
   services.grapevine = {
@@ -6,9 +11,9 @@
     enable = true;
     settings = {
       conduit_compat = true;
-#      address = "127.0.0.1";
+      #      address = "127.0.0.1";
       server_name = "conduit.rory.gay";
-      
+
       listen = [
         {
           type = "tcp";
@@ -30,4 +35,3 @@
     };
   };
 }
-
diff --git a/host/Rory-nginx/services/matrix/matrix-appservice-discord.nix b/host/Rory-nginx/services/matrix/matrix-appservice-discord.nix
index 8c31e10..43c26ca 100755
--- a/host/Rory-nginx/services/matrix/matrix-appservice-discord.nix
+++ b/host/Rory-nginx/services/matrix/matrix-appservice-discord.nix
@@ -1,8 +1,13 @@
-{ config, pkgs, lib, ... }:
+{
+  config,
+  pkgs,
+  lib,
+  ...
+}:
 
 {
   # Discord bridge
-   services.matrix-appservice-discord = {
+  services.matrix-appservice-discord = {
     enable = false; # Alicia - figure out secret first...
     environmentFile = /etc/keyring/matrix-appservice-discord/tokens.env;
     # The appservice is pre-configured to use SQLite by default.
@@ -20,7 +25,6 @@
         connString = "postgres://postgres@127.0.0.1/matrix-appservice-discord";
       };
     };
-   };
+  };
 
 }
-
diff --git a/host/Rory-nginx/services/matrix/matrix-media-gate.nix b/host/Rory-nginx/services/matrix/matrix-media-gate.nix
index fbec107..7eb599c 100755
--- a/host/Rory-nginx/services/matrix/matrix-media-gate.nix
+++ b/host/Rory-nginx/services/matrix/matrix-media-gate.nix
@@ -1,4 +1,10 @@
-{ config, pkgs, lib, MatrixMediaGate, ... }:
+{
+  config,
+  pkgs,
+  lib,
+  MatrixMediaGate,
+  ...
+}:
 
 {
   systemd.services = {
@@ -38,4 +44,3 @@
     };
   };
 }
-
diff --git a/host/Rory-nginx/services/matrix/root.nix b/host/Rory-nginx/services/matrix/root.nix
index 3ab3028..87b5cc9 100755
--- a/host/Rory-nginx/services/matrix/root.nix
+++ b/host/Rory-nginx/services/matrix/root.nix
@@ -1,14 +1,20 @@
-{ config, pkgs, lib, botcore-v4, ... }:
+{
+  config,
+  pkgs,
+  lib,
+  botcore-v4,
+  ...
+}:
 
 {
-  imports =
-    [
-      ./synapse/synapse-main.nix
-      ./coturn.nix
-      ./matrix-appservice-discord.nix
-      ./draupnir.nix
-      ./grapevine.nix
-      #./matrix-media-gate.nix
-    ];
+  imports = [
+    ./synapse/synapse-main.nix
+    ./coturn.nix
+    ./matrix-appservice-discord.nix
+    ./draupnir.nix
+    ./grapevine.nix
+    ./sliding-sync.nix
+    #./matrix-media-gate.nix
+  ];
 
-}
\ No newline at end of file
+}
diff --git a/host/Rory-nginx/services/matrix/sliding-sync.nix b/host/Rory-nginx/services/matrix/sliding-sync.nix
index bb028bd..e35113d 100644
--- a/host/Rory-nginx/services/matrix/sliding-sync.nix
+++ b/host/Rory-nginx/services/matrix/sliding-sync.nix
@@ -1,12 +1,12 @@
 { config }:
 {
-    services.matrix-sliding-sync = {
-      enable = true;
-      settings = {
-        "SYNCV3_SERVER" = "http://localhost:8008";
-        "SYNCV3_DB" = "postgresql://%2Frun%2Fpostgresql/syncv3";
-        "SYNCV3_BINDADDR" = "0.0.0.0:8100";
-      };
-      environmentFile = "/etc/sliding-sync.env";
+  services.matrix-sliding-sync = {
+    enable = true;
+    settings = {
+      "SYNCV3_SERVER" = "http://localhost:8008";
+      "SYNCV3_DB" = "postgresql://%2Frun%2Fpostgresql/syncv3";
+      "SYNCV3_BINDADDR" = "0.0.0.0:8100";
     };
-]
\ No newline at end of file
+    environmentFile = "/etc/sliding-sync.env";
+  };
+}
diff --git a/host/Rory-nginx/services/matrix/synapse/_synapse.monolith.nix b/host/Rory-nginx/services/matrix/synapse/_synapse.monolith.nix
index 26c61a1..8bdaf19 100755
--- a/host/Rory-nginx/services/matrix/synapse/_synapse.monolith.nix
+++ b/host/Rory-nginx/services/matrix/synapse/_synapse.monolith.nix
@@ -1,4 +1,9 @@
-{ config, pkgs, lib, ... }:
+{
+  config,
+  pkgs,
+  lib,
+  ...
+}:
 
 {
   services.matrix-synapse = {
@@ -25,7 +30,7 @@
         max_long_retry_delay = "30s";
       };
 
-      event_cache_size = "1200K"; #defaults to 10K
+      event_cache_size = "1200K"; # defaults to 10K
       caches = {
         global_factor = 5000.0;
         cache_entry_ttl = "12h";
@@ -41,18 +46,26 @@
       # Alicia - figure this out later...
       #registration_shared_secret = builtins.exec ["cat" "/dev/urandom" "|" "tr" "-dc" "a-zA-Z0-9" "|" "fold" "-w" "256" "|" "head" "-n" "1"];
       registration_shared_secret_path = "/var/lib/matrix-synapse/registration_shared_secret.txt";
-      
+
       listeners = [
-        { 
+        {
           port = 8008;
-          bind_addresses = [ "192.168.1.2" "127.0.0.1" ];
+          bind_addresses = [
+            "192.168.1.2"
+            "127.0.0.1"
+          ];
           type = "http";
           tls = false;
           x_forwarded = true;
-          resources = [ {
-            names = [ "client" "federation" ];
-            compress = true;
-          } ];
+          resources = [
+            {
+              names = [
+                "client"
+                "federation"
+              ];
+              compress = true;
+            }
+          ];
         }
       ];
       dynamic_thumbnails = true;
@@ -171,42 +184,41 @@
     plugins = with pkgs.matrix-synapse-plugins; [
       # Alicia - need to port draupnir...
       #matrix-synapse-mjolnir-antispam
-#      matrix-synapse-pam
+      #      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
-#          '';
-#        })
-#      ];
+    #    extraConfigFiles = [
+    #        (pkgs.writeTextFile {
+    #          name = "matrix-synapse-extra-config.yml";
+    #          text = ''
+    #            modules:
+    #              - module: "pam_auth_provider.PAMAuthProvider"
+    #                config:
+    #                  create_users: true
+    #                  skip_user_check: false
+    #          '';
+    #        })
+    #      ];
   };
 
-    systemd.services.matrix-synapse-reg-token = {
-      description = "Random registration token for Synapse.";
-      before = ["matrix-synapse.service"]; # So the registration can be used by Synapse
-      wantedBy = ["multi-user.target"];
-      after = ["network.target"];
-
-      script = ''
-
-        if [ ! -f "registration_shared_secret.txt" ]
-        then
-          cat /dev/urandom | tr -dc a-zA-Z0-9 | fold -w 256 | head -n 1 > registration_shared_secret.txt
-        else
-          echo Not generating key, key exists;
-        fi'';
-      serviceConfig = {
-        User = "matrix-synapse";
-        Group = "matrix-synapse";
-        WorkingDirectory = "/var/lib/matrix-synapse";
-      };
+  systemd.services.matrix-synapse-reg-token = {
+    description = "Random registration token for Synapse.";
+    before = [ "matrix-synapse.service" ]; # So the registration can be used by Synapse
+    wantedBy = [ "multi-user.target" ];
+    after = [ "network.target" ];
+
+    script = ''
+
+      if [ ! -f "registration_shared_secret.txt" ]
+      then
+        cat /dev/urandom | tr -dc a-zA-Z0-9 | fold -w 256 | head -n 1 > registration_shared_secret.txt
+      else
+        echo Not generating key, key exists;
+      fi'';
+    serviceConfig = {
+      User = "matrix-synapse";
+      Group = "matrix-synapse";
+      WorkingDirectory = "/var/lib/matrix-synapse";
     };
+  };
 
 }
-
diff --git a/host/Rory-nginx/services/matrix/synapse/caches.nix b/host/Rory-nginx/services/matrix/synapse/caches.nix
index 6196129..16fe0fc 100644
--- a/host/Rory-nginx/services/matrix/synapse/caches.nix
+++ b/host/Rory-nginx/services/matrix/synapse/caches.nix
@@ -1,7 +1,15 @@
 {
-  gc_min_interval = [ "15m" "30m" "60m" ];
-  gc_thresholds = [ 10000 5000 2500 ];
-  event_cache_size = "12000K"; #defaults to 10K
+  gc_min_interval = [
+    "15m"
+    "30m"
+    "60m"
+  ];
+  gc_thresholds = [
+    10000
+    5000
+    2500
+  ];
+  event_cache_size = "12000K"; # defaults to 10K
   caches = {
     global_factor = 500000.0;
     cache_entry_ttl = "24h";
@@ -13,4 +21,4 @@
       min_cache_ttl = "6h";
     };
   };
-}
\ No newline at end of file
+}
diff --git a/host/Rory-nginx/services/matrix/synapse/db.nix b/host/Rory-nginx/services/matrix/synapse/db.nix
index c5edc51..d8dcde3 100644
--- a/host/Rory-nginx/services/matrix/synapse/db.nix
+++ b/host/Rory-nginx/services/matrix/synapse/db.nix
@@ -1,7 +1,8 @@
-{ 
+{
   workerName ? null,
-  dbGroup ? null
-}: {
+  dbGroup ? null,
+}:
+{
   name = "psycopg2";
   args = {
     user = "matrix-synapse-rory-gay";
@@ -9,13 +10,23 @@
     database = "matrix-synapse-rory-gay";
     host = "/run/postgresql";
     application_name = "matrix-synapse (rory.gay) - ${if workerName == null then throw "synapse/db.nix: workerName unspecified" else workerName}";
-    cp_min = if dbGroup == "small" then 2
-      else if dbGroup == "medium" then 5
-      else if dbGroup == "large" then 10
-      else throw "synapse/db.nix: Invalid dbGroup: ${if dbGroup == null then "null" else dbGroup}";
-    cp_max = if dbGroup == "small" then 2
-      else if dbGroup == "medium" then 10
-      else if dbGroup == "large" then 10
-      else throw "synapse/db.nix: Invalid dbGroup: ${if dbGroup == null then "null" else dbGroup}";
+    cp_min =
+      if dbGroup == "small" then
+        2
+      else if dbGroup == "medium" then
+        5
+      else if dbGroup == "large" then
+        10
+      else
+        throw "synapse/db.nix: Invalid dbGroup: ${if dbGroup == null then "null" else dbGroup}";
+    cp_max =
+      if dbGroup == "small" then
+        2
+      else if dbGroup == "medium" then
+        10
+      else if dbGroup == "large" then
+        10
+      else
+        throw "synapse/db.nix: Invalid dbGroup: ${if dbGroup == null then "null" else dbGroup}";
   };
-}
\ No newline at end of file
+}
diff --git a/host/Rory-nginx/services/matrix/synapse/ratelimits.nix b/host/Rory-nginx/services/matrix/synapse/ratelimits.nix
index 8165fe4..4f6b7db 100644
--- a/host/Rory-nginx/services/matrix/synapse/ratelimits.nix
+++ b/host/Rory-nginx/services/matrix/synapse/ratelimits.nix
@@ -53,4 +53,4 @@
     concurrent = 100;
   };
   federation_rr_transactions_per_room_per_second = 1;
-}
\ No newline at end of file
+}
diff --git a/host/Rory-nginx/services/matrix/synapse/synapse-main.nix b/host/Rory-nginx/services/matrix/synapse/synapse-main.nix
index 4dc13a8..acd842f 100755
--- a/host/Rory-nginx/services/matrix/synapse/synapse-main.nix
+++ b/host/Rory-nginx/services/matrix/synapse/synapse-main.nix
@@ -1,11 +1,14 @@
-{ config, pkgs, lib, ... }:
+{
+  config,
+  pkgs,
+  lib,
+  ...
+}:
 
 {
   # Worker plumbing examples: https://github.com/element-hq/synapse/blob/master/docker/configure_workers_and_start.py
   # Documentation: https://github.com/element-hq/synapse/blob/develop/docs/workers.md
-  imports = [
-    ./workers/module.nix
-  ];
+  imports = [ ./workers/module.nix ];
 
   services.matrix-synapse = {
     enable = true;
@@ -39,26 +42,36 @@
       };
 
       registration_shared_secret_path = "/var/lib/matrix-synapse/registration_shared_secret.txt";
-      
+
       listeners = [
-        { 
+        {
           port = 8008;
-          bind_addresses = [ "192.168.1.2" "127.0.0.1" ];
+          bind_addresses = [
+            "192.168.1.2"
+            "127.0.0.1"
+          ];
           type = "http";
           tls = false;
           x_forwarded = true;
-          resources = [ {
-            names = [ "client" "federation" ];
-            compress = false;
-          } ];
+          resources = [
+            {
+              names = [
+                "client"
+                "federation"
+              ];
+              compress = false;
+            }
+          ];
         }
-        { 
+        {
           type = "http";
           path = "/run/matrix-synapse/main.sock";
-          resources = [ {
-            names = [ "replication" ];
-            compress = false;
-          } ];
+          resources = [
+            {
+              names = [ "replication" ];
+              compress = false;
+            }
+          ];
         }
       ];
       dynamic_thumbnails = true;
@@ -67,7 +80,12 @@
         update_interval = 60;
       };
       url_preview_enabled = true;
-      database = (import ./db.nix { workerName = "main"; dbGroup = "medium"; });
+      database = (
+        import ./db.nix {
+          workerName = "main";
+          dbGroup = "medium";
+        }
+      );
       app_service_config_files = [
         #"/etc/matrix-synapse/appservice-registration.yaml"
         "/var/lib/matrix-synapse/modas-registration.yaml"
@@ -101,28 +119,25 @@
         "msc3916_authenticated_media_enabled" = true; # Authenticated media
       };
 
-
       redis = {
         enabled = true;
         path = "/run/redis-matrix-synapse/redis.sock";
       };
 
-
       instance_map = {
-        main = { # replication listener
+        main = {
+          # replication listener
           path = "/run/matrix-synapse/main.sock";
         };
       };
-    }
-    // import ./ratelimits.nix
-    // import ./caches.nix;
+    } // import ./ratelimits.nix // import ./caches.nix;
   };
 
   systemd.services.matrix-synapse-reg-token = {
     description = "Random registration token for Synapse.";
-    before = ["matrix-synapse.service"]; # So the registration can be used by Synapse
-    wantedBy = ["multi-user.target"];
-    after = ["network.target"];
+    before = [ "matrix-synapse.service" ]; # So the registration can be used by Synapse
+    wantedBy = [ "multi-user.target" ];
+    after = [ "network.target" ];
 
     script = ''
 
@@ -146,8 +161,6 @@
       user = "matrix-synapse";
     };
   };
-  
-  systemd.tmpfiles.rules = [
-    "D /run/redis-matrix-synapse 0755 matrix-synapse matrix-synapse"
-  ];
-}
\ No newline at end of file
+
+  systemd.tmpfiles.rules = [ "D /run/redis-matrix-synapse 0755 matrix-synapse matrix-synapse" ];
+}
diff --git a/host/Rory-nginx/services/matrix/synapse/workers/appservice.nix b/host/Rory-nginx/services/matrix/synapse/workers/appservice.nix
index 5f1323c..d259edd 100644
--- a/host/Rory-nginx/services/matrix/synapse/workers/appservice.nix
+++ b/host/Rory-nginx/services/matrix/synapse/workers/appservice.nix
@@ -1,6 +1,11 @@
-{ config, pkgs, lib, ... }:
+{
+  config,
+  pkgs,
+  lib,
+  ...
+}:
 
-let 
+let
   cfg = config.services.matrix-synapse;
 in
 {
@@ -24,7 +29,7 @@ in
             path = "/run/matrix-synapse/appservice.sock";
             resources = [
               {
-                names = ["replication"];
+                names = [ "replication" ];
                 compress = false;
               }
             ];
@@ -33,4 +38,4 @@ in
       };
     };
   };
-}
\ No newline at end of file
+}
diff --git a/host/Rory-nginx/services/matrix/synapse/workers/background.nix b/host/Rory-nginx/services/matrix/synapse/workers/background.nix
index d267124..c97d647 100644
--- a/host/Rory-nginx/services/matrix/synapse/workers/background.nix
+++ b/host/Rory-nginx/services/matrix/synapse/workers/background.nix
@@ -1,6 +1,11 @@
-{ config, pkgs, lib, ... }:
+{
+  config,
+  pkgs,
+  lib,
+  ...
+}:
 
-let 
+let
   cfg = config.services.matrix-synapse;
 in
 {
@@ -24,7 +29,7 @@ in
             path = "/run/matrix-synapse/background.sock";
             resources = [
               {
-                names = ["replication"];
+                names = [ "replication" ];
                 compress = false;
               }
             ];
@@ -33,4 +38,4 @@ in
       };
     };
   };
-}
\ No newline at end of file
+}
diff --git a/host/Rory-nginx/services/matrix/synapse/workers/federation-sender.nix b/host/Rory-nginx/services/matrix/synapse/workers/federation-sender.nix
index c90fe3e..d0b1774 100644
--- a/host/Rory-nginx/services/matrix/synapse/workers/federation-sender.nix
+++ b/host/Rory-nginx/services/matrix/synapse/workers/federation-sender.nix
@@ -1,5 +1,10 @@
-{ config, pkgs, lib, ... }:
-let 
+{
+  config,
+  pkgs,
+  lib,
+  ...
+}:
+let
   cfg = config.services.matrix-synapse;
   federationSenders = lib.range 0 (cfg.federationSenders - 1);
 in
@@ -12,23 +17,25 @@ in
       outbound_federation_restricted_to = lib.map (index: "federation_sender-${toString index}") federationSenders;
     };
 
-    workers = lib.listToAttrs (lib.map (index: {
-      name = "federation_sender-${toString index}";
-      value = {
-        worker_app = "synapse.app.generic_worker";
-        worker_listeners = [
-          {
-            type = "http";
-            path = "/run/matrix-synapse/pusher-${toString index}.sock";
-            resources = [
-              {
-                names = ["replication"];
-                compress = false;
-              }
-            ];
-          }
-        ];
-      };
-    }) federationSenders);
+    workers = lib.listToAttrs (
+      lib.map (index: {
+        name = "federation_sender-${toString index}";
+        value = {
+          worker_app = "synapse.app.generic_worker";
+          worker_listeners = [
+            {
+              type = "http";
+              path = "/run/matrix-synapse/pusher-${toString index}.sock";
+              resources = [
+                {
+                  names = [ "replication" ];
+                  compress = false;
+                }
+              ];
+            }
+          ];
+        };
+      }) federationSenders
+    );
   };
-}
\ No newline at end of file
+}
diff --git a/host/Rory-nginx/services/matrix/synapse/workers/module.nix b/host/Rory-nginx/services/matrix/synapse/workers/module.nix
index 9cc3d92..b9c490e 100644
--- a/host/Rory-nginx/services/matrix/synapse/workers/module.nix
+++ b/host/Rory-nginx/services/matrix/synapse/workers/module.nix
@@ -1,14 +1,19 @@
-{ config, pkgs, lib, ... }:
+{
+  config,
+  pkgs,
+  lib,
+  ...
+}:
 let
   cfg = config.services.matrix-synapse;
-  #eventWriters = lib.range 0 (count - 1);
-  #typingWriters = lib.range 0 (count - 1);
-  #deviceWriters = lib.range 0 (count - 1);
-  #accountDataWriters = lib.range 0 (count - 1);
-  #receiptsWriters = lib.range 0 (count - 1);
-  #presenceWriters = lib.range 0 (count - 1);
-  #pusherWriters = lib.range 0 (count - 1);
 in
+#eventWriters = lib.range 0 (count - 1);
+#typingWriters = lib.range 0 (count - 1);
+#deviceWriters = lib.range 0 (count - 1);
+#accountDataWriters = lib.range 0 (count - 1);
+#receiptsWriters = lib.range 0 (count - 1);
+#presenceWriters = lib.range 0 (count - 1);
+#pusherWriters = lib.range 0 (count - 1);
 {
   imports = [
     ./federation-sender.nix
@@ -16,37 +21,43 @@ in
     ./pusher.nix
     ./stream-writers/event-stream-writer.nix
   ];
-  options.services.matrix-synapse = lib.listToAttrs (lib.map (option: {
-        name = "${option}StreamWriters";
-        value = lib.mkOption {
-          type = lib.types.int;
-          default = 0;
-          description = "Number of writers for ${option} streams";
-        };
-      }) [
-        "event"
-        "typing"
-        "toDevice"
-        "accountData"
-        "receipts"
-        "presence"
-        "pushRule"
-      ]) // {
-        enableStreamWriters = lib.mkEnableOption "Enable stream writers";
-        enableAppserviceWorker = lib.mkEnableOption "Enable dedicated appservice worker";
-        enableBackgroundWorker = lib.mkEnableOption "Enable dedicated background task worker";
+  options.services.matrix-synapse =
+    lib.listToAttrs (
+      lib.map
+        (option: {
+          name = "${option}StreamWriters";
+          value = lib.mkOption {
+            type = lib.types.int;
+            default = 0;
+            description = "Number of writers for ${option} streams";
+          };
+        })
+        [
+          "event"
+          "typing"
+          "toDevice"
+          "accountData"
+          "receipts"
+          "presence"
+          "pushRule"
+        ]
+    )
+    // {
+      enableStreamWriters = lib.mkEnableOption "Enable stream writers";
+      enableAppserviceWorker = lib.mkEnableOption "Enable dedicated appservice worker";
+      enableBackgroundWorker = lib.mkEnableOption "Enable dedicated background task worker";
 
-        federationSenders = lib.mkOption {
-          type = lib.types.int;
-          default = 0;
-          description = "Number of federation senders";
-        };
-        pushers = lib.mkOption {
-          type = lib.types.int;
-          default = 0;
-          description = "Number of pushers";
-        };
+      federationSenders = lib.mkOption {
+        type = lib.types.int;
+        default = 0;
+        description = "Number of federation senders";
+      };
+      pushers = lib.mkOption {
+        type = lib.types.int;
+        default = 0;
+        description = "Number of pushers";
       };
+    };
 
   config = lib.mkIf cfg.enableStreamWriters {
     #services.matrix-synapse = {
@@ -57,7 +68,7 @@ in
     #        path = "/run/matrix-synapse/stream-writer-${toString index}.sock";
     #      };
     #    }) federationSenders);
-#
+    #
     #    stream_writers = {
     #      events = lib.map (index: "stream-writer-events-${toString index}") federationSenders;
     #      typing = lib.map (index: "stream-writer-typing-${toString index}") typingWriters;
@@ -68,7 +79,7 @@ in
     #      push_rules = lib.map (index: "stream-writer-push_rules-${toString index}") pusherWriters;
     #    };
     #  };
-#
+    #
     #  workers = lib.listToAttrs (lib.map (index: {
     #    name = "stream-writerr-${toString index}";
     #    value = {
@@ -78,4 +89,4 @@ in
     #  }) federationSenders);
     #};
   };
-}
\ No newline at end of file
+}
diff --git a/host/Rory-nginx/services/matrix/synapse/workers/pusher.nix b/host/Rory-nginx/services/matrix/synapse/workers/pusher.nix
index c90561e..f5ef601 100644
--- a/host/Rory-nginx/services/matrix/synapse/workers/pusher.nix
+++ b/host/Rory-nginx/services/matrix/synapse/workers/pusher.nix
@@ -1,4 +1,9 @@
-{ config, pkgs, lib, ... }:
+{
+  config,
+  pkgs,
+  lib,
+  ...
+}:
 let
   cfg = config.services.matrix-synapse;
   pushers = lib.range 0 (cfg.pushers - 1);
@@ -7,34 +12,38 @@ in
   config = lib.mkIf (cfg.pushers > 0) {
     services.matrix-synapse = {
       settings = {
-        instance_map = lib.listToAttrs (lib.map (index: {
-          name = "pusher-${toString index}";
-          value = {
-            path = "/run/matrix-synapse/pusher-${toString index}.sock";
-          };
-        }) pushers);
+        instance_map = lib.listToAttrs (
+          lib.map (index: {
+            name = "pusher-${toString index}";
+            value = {
+              path = "/run/matrix-synapse/pusher-${toString index}.sock";
+            };
+          }) pushers
+        );
 
         pusher_instances = lib.map (index: "pusher-${toString index}") pushers;
       };
 
-      workers = lib.listToAttrs (lib.map (index: {
-        name = "pusher-${toString index}";
-        value = {
-          worker_app = "synapse.app.generic_worker";
-          worker_listeners = [
-            {
-              type = "http";
-              path = "/run/matrix-synapse/pusher-${toString index}.sock";
-              resources = [
-                {
-                  names = ["replication"];
-                  compress = false;
-                }
-              ];
-            }
-          ];
-        };
-      }) pushers);
+      workers = lib.listToAttrs (
+        lib.map (index: {
+          name = "pusher-${toString index}";
+          value = {
+            worker_app = "synapse.app.generic_worker";
+            worker_listeners = [
+              {
+                type = "http";
+                path = "/run/matrix-synapse/pusher-${toString index}.sock";
+                resources = [
+                  {
+                    names = [ "replication" ];
+                    compress = false;
+                  }
+                ];
+              }
+            ];
+          };
+        }) pushers
+      );
     };
   };
-}
\ No newline at end of file
+}
diff --git a/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/__OLD__module.nix b/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/__OLD__module.nix
index a661911..d4a9ff4 100644
--- a/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/__OLD__module.nix
+++ b/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/__OLD__module.nix
@@ -1,53 +1,66 @@
-{ config, pkgs, lib, ... }:
+{
+  config,
+  pkgs,
+  lib,
+  ...
+}:
 let
   cfg = config.services.matrix-synapse;
-  #eventWriters = lib.range 0 (count - 1);
-  #typingWriters = lib.range 0 (count - 1);
-  #deviceWriters = lib.range 0 (count - 1);
-  #accountDataWriters = lib.range 0 (count - 1);
-  #receiptsWriters = lib.range 0 (count - 1);
-  #presenceWriters = lib.range 0 (count - 1);
-  #pusherWriters = lib.range 0 (count - 1);
 in
+#eventWriters = lib.range 0 (count - 1);
+#typingWriters = lib.range 0 (count - 1);
+#deviceWriters = lib.range 0 (count - 1);
+#accountDataWriters = lib.range 0 (count - 1);
+#receiptsWriters = lib.range 0 (count - 1);
+#presenceWriters = lib.range 0 (count - 1);
+#pusherWriters = lib.range 0 (count - 1);
 {
-  options.services.matrix-synapse = lib.listToAttrs (lib.map (option: {
-        name = "${option}StreamWriters";
-        value = lib.mkOption {
-          type = lib.types.int;
-          default = 1;
-          description = "Number of writers for ${option} streams";
-        };
-      }) [
-        "event"
-        "typing"
-        "toDevice"
-        "accountData"
-        "receipts"
-        "presence"
-        "pushRule"
-      ]) // {
-        enableStreamWriters = lib.mkEnableOption "Enable stream writers";
-        federationSenders = lib.mkOption {
-          type = lib.types.int;
-          default = 1;
-          description = "Number of federation senders";
-        };
-        pushers = lib.mkOption {
-          type = lib.types.int;
-          default = 1;
-          description = "Number of pushers";
-        };
+  options.services.matrix-synapse =
+    lib.listToAttrs (
+      lib.map
+        (option: {
+          name = "${option}StreamWriters";
+          value = lib.mkOption {
+            type = lib.types.int;
+            default = 1;
+            description = "Number of writers for ${option} streams";
+          };
+        })
+        [
+          "event"
+          "typing"
+          "toDevice"
+          "accountData"
+          "receipts"
+          "presence"
+          "pushRule"
+        ]
+    )
+    // {
+      enableStreamWriters = lib.mkEnableOption "Enable stream writers";
+      federationSenders = lib.mkOption {
+        type = lib.types.int;
+        default = 1;
+        description = "Number of federation senders";
+      };
+      pushers = lib.mkOption {
+        type = lib.types.int;
+        default = 1;
+        description = "Number of pushers";
       };
+    };
 
   config = lib.mkIf cfg.enableStreamWriters {
     services.matrix-synapse = {
       settings = {
-        instance_map = lib.listToAttrs (lib.map (port: {
-          name = "stream-writer-${toString port}";
-          value = {
-            path = "/run/matrix-synapse/stream-writer-${toString port}.sock";
-          };
-        }) federationSenders);
+        instance_map = lib.listToAttrs (
+          lib.map (port: {
+            name = "stream-writer-${toString port}";
+            value = {
+              path = "/run/matrix-synapse/stream-writer-${toString port}.sock";
+            };
+          }) federationSenders
+        );
 
         stream_writers = {
           events = lib.map (port: "stream-writer-events-${toString port}") federationSenders;
@@ -60,13 +73,15 @@ in
         };
       };
 
-      workers = lib.listToAttrs (lib.map (port: {
-        name = "stream-writerr-${toString port}";
-        value = {
-          worker_app = "synapse.app.generic_worker";
-          worker_listeners = [ ];
-        };
-      }) federationSenders);
+      workers = lib.listToAttrs (
+        lib.map (port: {
+          name = "stream-writerr-${toString port}";
+          value = {
+            worker_app = "synapse.app.generic_worker";
+            worker_listeners = [ ];
+          };
+        }) federationSenders
+      );
     };
   };
-}
\ No newline at end of file
+}
diff --git a/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/event-stream-writer.nix b/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/event-stream-writer.nix
index af7e544..42e9251 100644
--- a/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/event-stream-writer.nix
+++ b/host/Rory-nginx/services/matrix/synapse/workers/stream-writers/event-stream-writer.nix
@@ -1,5 +1,9 @@
-
-{ config, pkgs, lib, ... }:
+{
+  config,
+  pkgs,
+  lib,
+  ...
+}:
 let
   cfg = config.services.matrix-synapse;
   streamWriters = lib.range 0 (cfg.eventStreamWriters - 1);
@@ -7,35 +11,39 @@ in
 {
   services.matrix-synapse = {
     settings = {
-      instance_map = lib.listToAttrs (lib.map (port: {
-        name = "stream-writer-${toString port}";
-        value = {
-          path = "/run/matrix-synapse/stream-writer-${toString port}.sock";
-        };
-      }) streamWriters);
+      instance_map = lib.listToAttrs (
+        lib.map (port: {
+          name = "stream-writer-${toString port}";
+          value = {
+            path = "/run/matrix-synapse/stream-writer-${toString port}.sock";
+          };
+        }) streamWriters
+      );
 
       stream_writers = {
         events = lib.map (index: "stream-writer-events-${toString index}") streamWriters;
       };
     };
 
-    workers = lib.listToAttrs (lib.map (index: {
-      name = "stream-writer-${toString index}";
-      value = {
-        worker_app = "synapse.app.generic_worker";
-        worker_listeners = [
-          {
-            type = "http";
-            path = "/run/matrix-synapse/stream-writer-${toString index}.sock";
-            resources = [
-              {
-                names = ["replication"];
-                compress = false;
-              }
-            ];
-          }
-        ];
-      };
-    }) streamWriters);
+    workers = lib.listToAttrs (
+      lib.map (index: {
+        name = "stream-writer-${toString index}";
+        value = {
+          worker_app = "synapse.app.generic_worker";
+          worker_listeners = [
+            {
+              type = "http";
+              path = "/run/matrix-synapse/stream-writer-${toString index}.sock";
+              resources = [
+                {
+                  names = [ "replication" ];
+                  compress = false;
+                }
+              ];
+            }
+          ];
+        };
+      }) streamWriters
+    );
   };
-}
\ No newline at end of file
+}