···1313 usePostgresql = cfg.settings.database.name == "psycopg2";
1414 hasLocalPostgresDB = let args = cfg.settings.database.args; in
1515 usePostgresql && (!(args ? host) || (elem args.host [ "localhost" "127.0.0.1" "::1" ]));
1616- hasWorkers = cfg.workers.enable && (cfg.workers.config != { });
1616+ hasWorkers = cfg.workers != { };
17171818 registerNewMatrixUser =
1919 let
···832832 workers = lib.mkOption {
833833 default = { };
834834 description = lib.mdDoc ''
835835- Options for configuring workers. See `services.matrix-synapse.workers.enable`
836836- for a more detailed description.
835835+ Options for configuring workers. Worker support will be enabled if at least one worker is configured here.
836836+837837+ See the [worker documention](https://matrix-org.github.io/synapse/latest/workers.html#worker-configuration)
838838+ for possible options for each worker. Worker-specific options overriding the shared homeserver configuration can be
839839+ specified here for each worker.
840840+841841+ ::: {.note}
842842+ Worker support will add a replication listener to the default
843843+ value of [`services.matrix-synapse.settings.listeners`](#opt-services.matrix-synapse.settings.listeners) and configure that
844844+ listener as `services.matrix-synapse.settings.instance_map.main`.
845845+ If you set either of those options, make sure to configure a replication listener yourself.
846846+847847+ A redis server is required for running workers. A local one can be enabled
848848+ using [`services.matrix-synapse.configureRedisLocally`](#opt-services.matrix-synapse.configureRedisLocally).
849849+ :::
837850 '';
838838- type = types.submodule {
851851+ type = types.attrsOf (types.submodule ({name, ...}: {
852852+ freeformType = format.type;
839853 options = {
840840- enable = lib.mkOption {
841841- type = types.bool;
842842- default = false;
854854+ worker_app = lib.mkOption {
855855+ type = types.enum [
856856+ "synapse.app.generic_worker"
857857+ "synapse.app.media_repository"
858858+ ];
859859+ description = "Type of this worker";
860860+ default = "synapse.app.generic_worker";
861861+ };
862862+ worker_listeners = lib.mkOption {
863863+ default = [ ];
864864+ type = types.listOf listenerType;
843865 description = lib.mdDoc ''
844844- Whether to enable matrix synapse workers.
845845-846846- ::: {.note}
847847- Enabling this will add a replication listener to the default
848848- value of `services.matrix-synapse.settings.listeners` and configure that
849849- listener as `services.matrix-synapse.settings.instance_map.main`.
850850- If you set either of those options, make sure to configure a replication
851851- listener yourself.
852852-853853- A redis server is required for running workers. A local one can be enabled
854854- using `services.matrix-synapse.configureRedisLocally`.
855855- :::
866866+ List of ports that this worker should listen on, their purpose and their configuration.
856867 '';
857868 };
858858- config = lib.mkOption {
859859- type = types.attrsOf (types.submodule ({name, ...}: {
860860- freeformType = format.type;
861861- options = {
862862- worker_app = lib.mkOption {
863863- type = types.enum [
864864- "synapse.app.generic_worker"
865865- "synapse.app.media_repository"
866866- ];
867867- description = "Type of this worker";
868868- default = "synapse.app.generic_worker";
869869- };
870870- worker_listeners = lib.mkOption {
871871- default = [ ];
872872- type = types.listOf listenerType;
873873- description = lib.mdDoc ''
874874- List of ports that this worker should listen on, their purpose and their configuration.
875875- '';
876876- };
877877- worker_log_config = lib.mkOption {
878878- type = types.path;
879879- default = genLogConfigFile "synapse-${name}";
880880- defaultText = logConfigText "synapse-${name}";
881881- description = lib.mdDoc ''
882882- The file for log configuration.
869869+ worker_log_config = lib.mkOption {
870870+ type = types.path;
871871+ default = genLogConfigFile "synapse-${name}";
872872+ defaultText = logConfigText "synapse-${name}";
873873+ description = lib.mdDoc ''
874874+ The file for log configuration.
883875884884- See the [python documentation](https://docs.python.org/3/library/logging.config.html#configuration-dictionary-schema)
885885- 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)
886886- for an example.
887887- '';
888888- };
889889- };
890890- }));
891891- default = { };
892892- description = lib.mdDoc ''
893893- List of workers to configure. See the
894894- [worker documention](https://matrix-org.github.io/synapse/latest/workers.html#worker-configuration)
895895- for possible values.
876876+ See the [python documentation](https://docs.python.org/3/library/logging.config.html#configuration-dictionary-schema)
877877+ 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)
878878+ for an example.
896879 '';
897897- example = lib.literalExpression ''
880880+ };
881881+ };
882882+ }));
883883+ default = { };
884884+ example = lib.literalExpression ''
885885+ {
886886+ "federation_sender" = { };
887887+ "federation_receiver" = {
888888+ worker_listeners = [
898889 {
899899- "federation_sender" = { };
900900- "federation_receiver" = {
901901- worker_listeners = [
902902- {
903903- type = "http";
904904- port = 8009;
905905- bind_addresses = [ "127.0.0.1" ];
906906- tls = false;
907907- x_forwarded = true;
908908- resources = [{
909909- names = [ "federation" ];
910910- }];
911911- }
912912- ];
913913- };
890890+ type = "http";
891891+ port = 8009;
892892+ bind_addresses = [ "127.0.0.1" ];
893893+ tls = false;
894894+ x_forwarded = true;
895895+ resources = [{
896896+ names = [ "federation" ];
897897+ }];
914898 }
915915- '';
899899+ ];
916900 };
917917- };
918918- };
901901+ }
902902+ '';
919903 };
920904921905 extraConfigFiles = mkOption {
···11311115 }
11321116 ];
11331117 }
11341134- // (lib.mapAttrs' genWorkerService cfg.workers.config);
11181118+ // (lib.mapAttrs' genWorkerService cfg.workers);
1135111911361120 services.redis.servers.matrix-synapse = lib.mkIf cfg.configureRedisLocally {
11371121 enable = true;