lol

nixos/synapse: move services.matrix-synapse.workers.config to services.matrix-synapse.workers

+61 -80
+60 -76
nixos/modules/services/matrix/synapse.nix
··· 13 13 usePostgresql = cfg.settings.database.name == "psycopg2"; 14 14 hasLocalPostgresDB = let args = cfg.settings.database.args; in 15 15 usePostgresql && (!(args ? host) || (elem args.host [ "localhost" "127.0.0.1" "::1" ])); 16 - hasWorkers = cfg.workers.enable && (cfg.workers.config != { }); 16 + hasWorkers = cfg.workers != { }; 17 17 18 18 registerNewMatrixUser = 19 19 let ··· 832 832 workers = lib.mkOption { 833 833 default = { }; 834 834 description = lib.mdDoc '' 835 - Options for configuring workers. See `services.matrix-synapse.workers.enable` 836 - for a more detailed description. 835 + Options for configuring workers. Worker support will be enabled if at least one worker is configured here. 836 + 837 + See the [worker documention](https://matrix-org.github.io/synapse/latest/workers.html#worker-configuration) 838 + for possible options for each worker. Worker-specific options overriding the shared homeserver configuration can be 839 + specified here for each worker. 840 + 841 + ::: {.note} 842 + Worker support will add a replication listener to the default 843 + value of [`services.matrix-synapse.settings.listeners`](#opt-services.matrix-synapse.settings.listeners) and configure that 844 + listener as `services.matrix-synapse.settings.instance_map.main`. 845 + If you set either of those options, make sure to configure a replication listener yourself. 846 + 847 + A redis server is required for running workers. A local one can be enabled 848 + using [`services.matrix-synapse.configureRedisLocally`](#opt-services.matrix-synapse.configureRedisLocally). 849 + ::: 837 850 ''; 838 - type = types.submodule { 851 + type = types.attrsOf (types.submodule ({name, ...}: { 852 + freeformType = format.type; 839 853 options = { 840 - enable = lib.mkOption { 841 - type = types.bool; 842 - default = false; 854 + worker_app = lib.mkOption { 855 + type = types.enum [ 856 + "synapse.app.generic_worker" 857 + "synapse.app.media_repository" 858 + ]; 859 + description = "Type of this worker"; 860 + default = "synapse.app.generic_worker"; 861 + }; 862 + worker_listeners = lib.mkOption { 863 + default = [ ]; 864 + type = types.listOf listenerType; 843 865 description = lib.mdDoc '' 844 - Whether to enable matrix synapse workers. 845 - 846 - ::: {.note} 847 - Enabling this will add a replication listener to the default 848 - value of `services.matrix-synapse.settings.listeners` and configure that 849 - listener as `services.matrix-synapse.settings.instance_map.main`. 850 - If you set either of those options, make sure to configure a replication 851 - listener yourself. 852 - 853 - A redis server is required for running workers. A local one can be enabled 854 - using `services.matrix-synapse.configureRedisLocally`. 855 - ::: 866 + List of ports that this worker should listen on, their purpose and their configuration. 856 867 ''; 857 868 }; 858 - config = lib.mkOption { 859 - type = types.attrsOf (types.submodule ({name, ...}: { 860 - freeformType = format.type; 861 - options = { 862 - worker_app = lib.mkOption { 863 - type = types.enum [ 864 - "synapse.app.generic_worker" 865 - "synapse.app.media_repository" 866 - ]; 867 - description = "Type of this worker"; 868 - default = "synapse.app.generic_worker"; 869 - }; 870 - worker_listeners = lib.mkOption { 871 - default = [ ]; 872 - type = types.listOf listenerType; 873 - description = lib.mdDoc '' 874 - List of ports that this worker should listen on, their purpose and their configuration. 875 - ''; 876 - }; 877 - worker_log_config = lib.mkOption { 878 - type = types.path; 879 - default = genLogConfigFile "synapse-${name}"; 880 - defaultText = logConfigText "synapse-${name}"; 881 - description = lib.mdDoc '' 882 - The file for log configuration. 869 + worker_log_config = lib.mkOption { 870 + type = types.path; 871 + default = genLogConfigFile "synapse-${name}"; 872 + defaultText = logConfigText "synapse-${name}"; 873 + description = lib.mdDoc '' 874 + The file for log configuration. 883 875 884 - See the [python documentation](https://docs.python.org/3/library/logging.config.html#configuration-dictionary-schema) 885 - 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) 886 - for an example. 887 - ''; 888 - }; 889 - }; 890 - })); 891 - default = { }; 892 - description = lib.mdDoc '' 893 - List of workers to configure. See the 894 - [worker documention](https://matrix-org.github.io/synapse/latest/workers.html#worker-configuration) 895 - for possible values. 876 + See the [python documentation](https://docs.python.org/3/library/logging.config.html#configuration-dictionary-schema) 877 + 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) 878 + for an example. 896 879 ''; 897 - example = lib.literalExpression '' 880 + }; 881 + }; 882 + })); 883 + default = { }; 884 + example = lib.literalExpression '' 885 + { 886 + "federation_sender" = { }; 887 + "federation_receiver" = { 888 + worker_listeners = [ 898 889 { 899 - "federation_sender" = { }; 900 - "federation_receiver" = { 901 - worker_listeners = [ 902 - { 903 - type = "http"; 904 - port = 8009; 905 - bind_addresses = [ "127.0.0.1" ]; 906 - tls = false; 907 - x_forwarded = true; 908 - resources = [{ 909 - names = [ "federation" ]; 910 - }]; 911 - } 912 - ]; 913 - }; 890 + type = "http"; 891 + port = 8009; 892 + bind_addresses = [ "127.0.0.1" ]; 893 + tls = false; 894 + x_forwarded = true; 895 + resources = [{ 896 + names = [ "federation" ]; 897 + }]; 914 898 } 915 - ''; 899 + ]; 916 900 }; 917 - }; 918 - }; 901 + } 902 + ''; 919 903 }; 920 904 921 905 extraConfigFiles = mkOption { ··· 1131 1115 } 1132 1116 ]; 1133 1117 } 1134 - // (lib.mapAttrs' genWorkerService cfg.workers.config); 1118 + // (lib.mapAttrs' genWorkerService cfg.workers); 1135 1119 1136 1120 services.redis.servers.matrix-synapse = lib.mkIf cfg.configureRedisLocally { 1137 1121 enable = true;
+1 -4
nixos/tests/matrix/synapse-workers.nix
··· 35 35 }; 36 36 configureRedisLocally = true; 37 37 workers = { 38 - enable = true; 39 - config = { 40 - "federation_sender" = { }; 41 - }; 38 + "federation_sender" = { }; 42 39 }; 43 40 }; 44 41 };