summaryrefslogtreecommitdiffstats
path: root/nixos/modules/services/matrix
diff options
context:
space:
mode:
authorSophie Tauchert <sophie@999eagle.moe>2023-09-10 15:35:59 +0200
committerSophie Tauchert <sophie@999eagle.moe>2023-09-18 08:24:37 +0200
commitca1ffe586948c3e5446387fe15ee241d0cd153ec (patch)
treec80410db0914a86d279b5da1cb5e5aa4f1f96c7c /nixos/modules/services/matrix
parent53ab84cf49a6146de35f31f81960185ff6075d55 (diff)
nixos/synapse: move services.matrix-synapse.workers.config to services.matrix-synapse.workers
Diffstat (limited to 'nixos/modules/services/matrix')
-rw-r--r--nixos/modules/services/matrix/synapse.nix136
1 files changed, 60 insertions, 76 deletions
diff --git a/nixos/modules/services/matrix/synapse.nix b/nixos/modules/services/matrix/synapse.nix
index f7ae3fa89536..25d3e3dcd1b9 100644
--- a/nixos/modules/services/matrix/synapse.nix
+++ b/nixos/modules/services/matrix/synapse.nix
@@ -13,7 +13,7 @@ let
usePostgresql = cfg.settings.database.name == "psycopg2";
hasLocalPostgresDB = let args = cfg.settings.database.args; in
usePostgresql && (!(args ? host) || (elem args.host [ "localhost" "127.0.0.1" "::1" ]));
- hasWorkers = cfg.workers.enable && (cfg.workers.config != { });
+ hasWorkers = cfg.workers != { };
registerNewMatrixUser =
let
@@ -832,90 +832,74 @@ in {
workers = lib.mkOption {
default = { };
description = lib.mdDoc ''
- Options for configuring workers. See `services.matrix-synapse.workers.enable`
- for a more detailed description.
+ Options for configuring workers. Worker support will be enabled if at least one worker is configured here.
+
+ See the [worker documention](https://matrix-org.github.io/synapse/latest/workers.html#worker-configuration)
+ for possible options for each worker. Worker-specific options overriding the shared homeserver configuration can be
+ specified here for each worker.
+
+ ::: {.note}
+ Worker support will add a replication listener to the default
+ value of [`services.matrix-synapse.settings.listeners`](#opt-services.matrix-synapse.settings.listeners) and configure that
+ listener as `services.matrix-synapse.settings.instance_map.main`.
+ If you set either of those options, make sure to configure a replication listener yourself.
+
+ A redis server is required for running workers. A local one can be enabled
+ using [`services.matrix-synapse.configureRedisLocally`](#opt-services.matrix-synapse.configureRedisLocally).
+ :::
'';
- type = types.submodule {
+ type = types.attrsOf (types.submodule ({name, ...}: {
+ freeformType = format.type;
options = {
- enable = lib.mkOption {
- type = types.bool;
- default = false;
+ worker_app = lib.mkOption {
+ type = types.enum [
+ "synapse.app.generic_worker"
+ "synapse.app.media_repository"
+ ];
+ description = "Type of this worker";
+ default = "synapse.app.generic_worker";
+ };
+ worker_listeners = lib.mkOption {
+ default = [ ];
+ type = types.listOf listenerType;
description = lib.mdDoc ''
- Whether to enable matrix synapse workers.
-
- ::: {.note}
- Enabling this will add a replication listener to the default
- value of `services.matrix-synapse.settings.listeners` and configure that
- listener as `services.matrix-synapse.settings.instance_map.main`.
- If you set either of those options, make sure to configure a replication
- listener yourself.
-
- A redis server is required for running workers. A local one can be enabled
- using `services.matrix-synapse.configureRedisLocally`.
- :::
+ List of ports that this worker should listen on, their purpose and their configuration.
'';
};
- config = lib.mkOption {
- type = types.attrsOf (types.submodule ({name, ...}: {
- freeformType = format.type;
- options = {
- worker_app = lib.mkOption {
- type = types.enum [
- "synapse.app.generic_worker"
- "synapse.app.media_repository"
- ];
- description = "Type of this worker";
- default = "synapse.app.generic_worker";
- };
- worker_listeners = lib.mkOption {
- default = [ ];
- type = types.listOf listenerType;
- description = lib.mdDoc ''
- List of ports that this worker should listen on, their purpose and their configuration.
- '';
- };
- worker_log_config = lib.mkOption {
- type = types.path;
- default = genLogConfigFile "synapse-${name}";
- defaultText = logConfigText "synapse-${name}";
- description = lib.mdDoc ''
- The file for log configuration.
-
- See the [python documentation](https://docs.python.org/3/library/logging.config.html#configuration-dictionary-schema)
- for the schema and the [upstream repository](https://github.com/matrix-org/synapse/blob/v${pkgs.matrix-synapse-unwrapped.version}/docs/sample_log_config.yaml)
- for an example.
- '';
- };
- };
- }));
- default = { };
+ worker_log_config = lib.mkOption {
+ type = types.path;
+ default = genLogConfigFile "synapse-${name}";
+ defaultText = logConfigText "synapse-${name}";
description = lib.mdDoc ''
- List of workers to configure. See the
- [worker documention](https://matrix-org.github.io/synapse/latest/workers.html#worker-configuration)
- for possible values.
+ The file for log configuration.
+
+ See the [python documentation](https://docs.python.org/3/library/logging.config.html#configuration-dictionary-schema)
+ for the schema and the [upstream repository](https://github.com/matrix-org/synapse/blob/v${pkgs.matrix-synapse-unwrapped.version}/docs/sample_log_config.yaml)
+ for an example.
'';
- example = lib.literalExpression ''
+ };
+ };
+ }));
+ default = { };
+ example = lib.literalExpression ''
+ {
+ "federation_sender" = { };
+ "federation_receiver" = {
+ worker_listeners = [
{
- "federation_sender" = { };
- "federation_receiver" = {
- worker_listeners = [
- {
- type = "http";
- port = 8009;
- bind_addresses = [ "127.0.0.1" ];
- tls = false;
- x_forwarded = true;
- resources = [{
- names = [ "federation" ];
- }];
- }
- ];
- };
+ type = "http";
+ port = 8009;
+ bind_addresses = [ "127.0.0.1" ];
+ tls = false;
+ x_forwarded = true;
+ resources = [{
+ names = [ "federation" ];
+ }];
}
- '';
+ ];
};
- };
- };
+ }
+ '';
};
extraConfigFiles = mkOption {
@@ -1131,7 +1115,7 @@ in {
}
];
}
- // (lib.mapAttrs' genWorkerService cfg.workers.config);
+ // (lib.mapAttrs' genWorkerService cfg.workers);
services.redis.servers.matrix-synapse = lib.mkIf cfg.configureRedisLocally {
enable = true;