summary refs log tree commit diff
path: root/host/Rory-nginx/services/matrix/synapse/workers/module.nix
blob: 2ab1d10e17cfb663aa876f97017238587b67a326 (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
{
  config,
  pkgs,
  lib,
  ...
}:
let
  cfg = config.services.matrix-synapse;
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 = [
    ./appservice.nix
    ./background.nix
    ./federation-sender.nix
    ./media-repo.nix
    ./pusher.nix
    ./sync.nix
    ./user-dir.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";
      enableUserDirWorker = lib.mkEnableOption "Enable dedicated user directory 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";
      };
      mediaRepoWorkers = lib.mkOption {
        type = lib.types.int;
        default = 0;
        description = "Number of media repo workers";
      };
      syncWorkers = lib.mkOption {
        type = lib.types.int;
        default = 0;
        description = "Number of sync workers";
      };
      clientReaders = lib.mkOption {
        type = lib.types.int;
        default = 0;
        description = "Number of client readers";
      };

      nginxVirtualHostName = lib.mkOption {
        type = lib.types.str;
        default = null;
        description = "The virtual host name for the nginx server";
      };
    };

  config = {
    assertions = [
      {
        assertion = cfg.enableUserDirWorker -> cfg.nginxVirtualHostName != null;
        message = "nginxVirtualHostName must be set when enableUserDirWorker is true";
      }
    ];
  };
}