summary refs log tree commit diff
path: root/host/Rory-nginx/services/matrix/synapse/workers/user-dir.nix
blob: 75ba121c73c5080843d6df41549f548f20fd1f78 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{
  config,
  pkgs,
  lib,
  ...
}:

let
  cfg = config.services.matrix-synapse;
in
{
  config = lib.mkIf cfg.enableUserDirWorker {
    services.matrix-synapse = {
      settings = {
        instance_map = {
          user_dir = {
            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";
              mode = 666;
              resources = [
                {
                  names = [ "client" ];
                  compress = false;
                }
              ];
            }
          ];
          database = (
            import ../db.nix {
              workerName = "user_dir";
              dbGroup = "small";
            }
          );
        };
      };
    };

    services.nginx.virtualHosts."${cfg.nginxVirtualHostName}" = {
      locations."~ ^/_matrix/client/(api/v1|r0|v3|unstable)/user_directory/search$" = {
        proxyPass = "http://unix:/run/matrix-synapse/user_dir-client.sock";
      };
    };
  };
}