summary refs log tree commit diff
path: root/host/Rory-nginx/services/matrix/synapse/workers/user-dir.nix
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2024-07-04 16:38:18 +0200
committerRory& <root@rory.gay>2024-07-04 16:38:18 +0200
commit22827997825f30a8c9c42534128f1756287ae80d (patch)
tree1a4aaabac9b7838ecc9ed2199c88fef056193ce3 /host/Rory-nginx/services/matrix/synapse/workers/user-dir.nix
parentFederation senders on instance map (diff)
downloadRory-Open-Architecture-22827997825f30a8c9c42534128f1756287ae80d.tar.xz
User dir worker
Diffstat (limited to 'host/Rory-nginx/services/matrix/synapse/workers/user-dir.nix')
-rw-r--r--host/Rory-nginx/services/matrix/synapse/workers/user-dir.nix66
1 files changed, 66 insertions, 0 deletions
diff --git a/host/Rory-nginx/services/matrix/synapse/workers/user-dir.nix b/host/Rory-nginx/services/matrix/synapse/workers/user-dir.nix
new file mode 100644
index 0000000..4a097af
--- /dev/null
+++ b/host/Rory-nginx/services/matrix/synapse/workers/user-dir.nix
@@ -0,0 +1,66 @@
+{
+  config,
+  pkgs,
+  lib,
+  ...
+}:
+
+let
+  cfg = config.services.matrix-synapse;
+in
+{
+  config = lib.mkIf cfg.enableUserDirWorker {
+    services.matrix-synapse = {
+      settings = {
+        instance_map = {
+          appservice = {
+            path = "/run/matrix-synapse/user_dir.sock";
+          };
+        };
+
+        update_user_directory_from_worker = "user_dir";
+      };
+
+      workers = {
+        user_dir = {
+          worker_app = "synapse.app.generic_worker";
+          worker_listeners = [
+            {
+              type = "http";
+              path = "/run/matrix-synapse/user_dir.sock";
+              resources = [
+                {
+                  names = [ "replication" ];
+                  compress = false;
+                }
+              ];
+            }
+            {
+              type = "http";
+              path = "/run/matrix-synapse/user_dir-client.sock";
+              resources = [
+                {
+                  names = [ "client" ];
+                  compress = false;
+                }
+              ];
+            }
+          ];
+
+          database = (
+            import ../db.nix {
+              workerName = "user_dir";
+              dbGroup = "small";
+            }
+          );
+        };
+      };
+    };
+
+    services.nginx.virtualHosts."${nginxVirtualHostName}" = {
+      locations."^/_matrix/client/(api/v1|r0|v3|unstable)/user_directory/search$" = {
+        proxyPass = "http://unix:/run/matrix-synapse/user_dir-client.sock";
+      };
+    };
+  };
+}