···68686969- The `services.ananicy.extraRules` option now has the type of `listOf attrs` instead of `string`.
70707171+- The `matrix-synapse` package & module have undergone some significant internal changes, for most setups no intervention is needed, though:
7272+ - The option [`services.matrix-synapse.package`](#opt-services.matrix-synapse.package) is now read-only. For modifying the package, use an overlay which modifies `matrix-synapse-unwrapped` instead. More on that below.
7373+ - The `enableSystemd` & `enableRedis` arguments have been removed and `matrix-synapse` has been renamed to `matrix-synapse-unwrapped`. Also, several optional dependencies (such as `psycopg2` or `authlib`) have been removed.
7474+ - These optional dependencies are automatically added via a wrapper (`pkgs.matrix-synapse.override { extras = ["redis"]; }` for `hiredis` & `txredisapi` for instance) if the relevant config section is declared in `services.matrix-synapse.settings`. For instance, if `services.matrix-synapse.settings.redis.enabled` is set to `true`, `"redis"` will be automatically added to the `extras` list of `pkgs.matrix-synapse`.
7575+ - A list of all extras (and the extras enabled by default) can be found at the [option's reference for `services.matrix-synapse.extras`](#opt-services.matrix-synapse.extras).
7676+ - In some cases (e.g. for running synapse workers) it was necessary to re-use the `PYTHONPATH` of `matrix-synapse.service`'s environment to have all plugins available. This isn't necessary anymore, instead `config.services.matrix-synapse.package` can be used as it points to the wrapper with properly configured `extras` and also all plugins defined via [`services.matrix-synapse.plugins`](#opt-services.matrix-synapse.plugins) available. This is also the reason for why the option is read-only now, it's supposed to be set by the module only.
7777+7178- `etcd` has been updated to 3.5, you will want to read the [3.3 to 3.4](https://etcd.io/docs/v3.5/upgrades/upgrade_3_4/) and [3.4 to 3.5](https://etcd.io/docs/v3.5/upgrades/upgrade_3_5/) upgrade guides
72797380- `consul` has been updated to `1.16.0`. See the [release note](https://github.com/hashicorp/consul/releases/tag/v1.16.0) for more details. Once a new Consul version has started and upgraded its data directory, it generally cannot be downgraded to the previous version.
+75-12
nixos/modules/services/matrix/synapse.nix
···99 # remove null values from the final configuration
1010 finalSettings = lib.filterAttrsRecursive (_: v: v != null) cfg.settings;
1111 configFile = format.generate "homeserver.yaml" finalSettings;
1212- logConfigFile = format.generate "log_config.yaml" cfg.logConfig;
1313-1414- pluginsEnv = cfg.package.python.buildEnv.override {
1515- extraLibs = cfg.plugins;
1616- };
17121813 usePostgresql = cfg.settings.database.name == "psycopg2";
1914 hasLocalPostgresDB = let args = cfg.settings.database.args; in
···5045 "${bindAddress}"
5146 }:${builtins.toString listener.port}/"
5247 '';
4848+4949+ defaultExtras = [
5050+ "systemd"
5151+ "postgres"
5252+ "url-preview"
5353+ "user-search"
5454+ ];
5555+5656+ wantedExtras = cfg.extras
5757+ ++ lib.optional (cfg.settings ? oidc_providers) "oidc"
5858+ ++ lib.optional (cfg.settings ? jwt_config) "jwt"
5959+ ++ lib.optional (cfg.settings ? saml2_config) "saml2"
6060+ ++ lib.optional (cfg.settings ? opentracing) "opentracing"
6161+ ++ lib.optional (cfg.settings ? redis) "redis"
6262+ ++ lib.optional (cfg.settings ? sentry) "sentry"
6363+ ++ lib.optional (cfg.settings ? user_directory) "user-search"
6464+ ++ lib.optional (cfg.settings.url_preview_enabled) "url-preview"
6565+ ++ lib.optional (cfg.settings.database.name == "psycopg2") "postgres";
6666+6767+ wrapped = pkgs.matrix-synapse.override {
6868+ extras = wantedExtras;
6969+ inherit (cfg) plugins;
7070+ };
5371in {
54725573 imports = [
···151169152170 package = mkOption {
153171 type = types.package;
154154- default = pkgs.matrix-synapse;
155155- defaultText = literalExpression "pkgs.matrix-synapse";
172172+ readOnly = true;
173173+ description = lib.mdDoc ''
174174+ Reference to the `matrix-synapse` wrapper with all extras
175175+ (e.g. for `oidc` or `saml2`) added to the `PYTHONPATH` of all executables.
176176+177177+ This option is useful to reference the "final" `matrix-synapse` package that's
178178+ actually used by `matrix-synapse.service`. For instance, when using
179179+ workers, it's possible to run
180180+ `''${config.services.matrix-synapse.package}/bin/synapse_worker` and
181181+ no additional PYTHONPATH needs to be specified for extras or plugins configured
182182+ via `services.matrix-synapse`.
183183+184184+ However, this means that this option is supposed to be only declared
185185+ by the `services.matrix-synapse` module itself and is thus read-only.
186186+ In order to modify `matrix-synapse` itself, use an overlay to override
187187+ `pkgs.matrix-synapse-unwrapped`.
188188+ '';
189189+ };
190190+191191+ extras = mkOption {
192192+ type = types.listOf (types.enum (lib.attrNames pkgs.matrix-synapse-unwrapped.optional-dependencies));
193193+ default = defaultExtras;
194194+ example = literalExpression ''
195195+ [
196196+ "cache-memory" # Provide statistics about caching memory consumption
197197+ "jwt" # JSON Web Token authentication
198198+ "opentracing" # End-to-end tracing support using Jaeger
199199+ "oidc" # OpenID Connect authentication
200200+ "postgres" # PostgreSQL database backend
201201+ "redis" # Redis support for the replication stream between worker processes
202202+ "saml2" # SAML2 authentication
203203+ "sentry" # Error tracking and performance metrics
204204+ "systemd" # Provide the JournalHandler used in the default log_config
205205+ "url-preview" # Support for oEmbed URL previews
206206+ "user-search" # Support internationalized domain names in user-search
207207+ ]
208208+ '';
156209 description = lib.mdDoc ''
157157- Overridable attribute of the matrix synapse server package to use.
210210+ Explicitly install extras provided by matrix-synapse. Most
211211+ will require some additional configuration.
212212+213213+ Extras will automatically be enabled, when the relevant
214214+ configuration sections are present.
215215+216216+ Please note that this option is additive: i.e. when adding a new item
217217+ to this list, the defaults are still kept. To override the defaults as well,
218218+ use `lib.mkForce`.
158219 '';
159220 };
160221···193254 default = {};
194255 description = mdDoc ''
195256 The primary synapse configuration. See the
196196- [sample configuration](https://github.com/matrix-org/synapse/blob/v${cfg.package.version}/docs/sample_config.yaml)
257257+ [sample configuration](https://github.com/matrix-org/synapse/blob/v${pkgs.matrix-synapse-unwrapped.version}/docs/sample_config.yaml)
197258 for possible values.
198259199260 Secrets should be passed in by using the `extraConfigFiles` option.
···706767 ];
707768708769 services.matrix-synapse.configFile = configFile;
770770+ services.matrix-synapse.package = wrapped;
771771+772772+ # default them, so they are additive
773773+ services.matrix-synapse.extras = defaultExtras;
709774710775 users.users.matrix-synapse = {
711776 group = "matrix-synapse";
···729794 --keys-directory ${cfg.dataDir} \
730795 --generate-keys
731796 '';
732732- environment = {
733733- PYTHONPATH = makeSearchPathOutput "lib" cfg.package.python.sitePackages [ pluginsEnv ];
734734- } // optionalAttrs (cfg.withJemalloc) {
797797+ environment = optionalAttrs (cfg.withJemalloc) {
735798 LD_PRELOAD = "${pkgs.jemalloc}/lib/libjemalloc.so";
736799 };
737800 serviceConfig = {