Commit graph

119 commits

Author SHA1 Message Date
Martin Weinelt 457d9bbc94
nixos/matrix-synapse: wait for network-online.target
While network.target only guarantees that network devices have been
created the `network-online.target` allows delaying service startup
until after a configurable network state has been reached.

This should resolve spurious failures, e.g. when synapse tries to load
the discovery information for its OIDC provider from a remote host.
2023-09-22 22:41:40 +02:00
Maximilian Bosch d004375485
nixos/matrix-synapse: refactor assertions for missing listener resources
While reviewing other changes related to synapse I rediscovered the
`lib.findFirst (...) (lib.last resources)` hack to find a listener
supporting the `client` resource. We decided to keep it that way for now
a while ago to avoid scope-creep on the RFC42 refactoring[1]. I wanted
to take care of that and forgot about it.

Anyways, I'm pretty sure that this is bogus: to register a user, you
need the `client` API and not a random listener which happens to be the
last one in the list. Also, you need something which serves the `client`
API to have the entire synapse<->messenger interaction working (whereas
`federation` is for synapse<->synapse).

So I decided to error out if no `client` listener is found. A listener
serving `client` can be defined in either the main synapse process or
one of its workers via `services.matrix-synapse.workers`[2].

However it's generally nicer to use assertions for that because then
it's possible to display multiple configuration errors at once and one
doesn't have to chase one `throw` after another. I decided to also error
out when using the result from `findFirst` though because module
assertions aren't thrown necessarily when you evaluate a single config
attribute, e.g. `config.environment.systemPackages` which depends on an
existing client listener because of `registerNewMatrixUser`[3].

While at it I realized that if `settings.instance_map` is wrongly
configured, e.g. by

    settings.instance_map = mkForce {
      /* no `main` in here */
    }

an `attribute ... missing` error will be thrown while evaluating the
worker assertion.

[1] https://github.com/NixOS/nixpkgs/pull/158605#discussion_r815500487
[2] This also means that `registerNewMatrixUser` will still work if you
    offload the entire `client` traffic to a worker.
[3] And getting a useful error message is way better for debugging in such a
    case than `value is null while a set was expected`.
2023-09-20 15:48:03 +02:00
Sophie Tauchert 24f6a70abf
nixos/synapse: make sure workers require main process
This should ensure systemd handles starting all services (main and
workers) in a single transaction, thus preserving unit orderings
defined through After= even when not restarting the target.
2023-09-18 10:52:54 +02:00
Sophie Tauchert aed8a5c6cd
nixos/synapse: add documentation for required reverse proxy setup 2023-09-18 08:24:38 +02:00
Sophie Tauchert dea34ad0fa
nixos/synapse: default tls to off for workers and document worker replication port 2023-09-18 08:24:37 +02:00
Sophie Tauchert c693c2fd96
nixos/synapse: simplify replication listener assertion 2023-09-18 08:24:37 +02:00
Sophie Tauchert ca1ffe5869
nixos/synapse: move services.matrix-synapse.workers.config to services.matrix-synapse.workers 2023-09-18 08:24:37 +02:00
Sophie Tauchert 53ab84cf49
nixos/synapse: automatically configure logging for synapse and workers 2023-09-18 08:24:36 +02:00
Sophie Tauchert 857b4932ec
nixos/synapse: remove obsolete log context
see 0304ad0c3d for when this was removed upstream
2023-09-18 08:24:36 +02:00
Sophie Tauchert 2edea7611b
nixos/synapse: document options better
Co-authored-by: Daniel Olsen <daniel.olsen99@gmail.com>
2023-09-18 08:24:36 +02:00
Sophie Tauchert 3a6a07ecf1
nixos/synapse: automatically configure replication listener 2023-09-18 08:24:35 +02:00
Sophie Tauchert 72a26e2b54
nixos/synapse: add options to configure workers 2023-09-18 08:24:35 +02:00
Sophie Tauchert b329180128
nixos/synapse: add option to configure redis automatically 2023-09-18 08:24:35 +02:00
Sophie Tauchert b7c41da8d6
nixos/synapse: update listener settings
The resource type health is currently missing, but should be available
according to https://matrix-org.github.io/synapse/latest/usage/configuration/config_documentation.html#listeners
2023-09-18 08:24:35 +02:00
Sophie Tauchert f15212aad8
nixos/synapse: cleanup, split out listener type and service config 2023-09-18 08:24:33 +02:00
Maximilian Bosch 8a3c21bd82
nixos/matrix-synapse: fix type of settings.url_preview_url_blacklist
Actually, it's supposed to be `listOf (attrsOf str)` because each
list-item can match against multiple properties from `urlsplit`[1]. In
fact, `listOf str` breaks URL previews at runtime:

    Sep 14 15:03:47 soost synapse[1100355]: synapse.http.server: [GET-116] Failed handle request via 'PreviewUrlResource': <XForwardedForRequest at 0x7f691bd5f730 method='GET' uri='/_matrix/media/r0/preview_url?url=<redacted>' clientproto='HTTP/1.1' site='8448'>
                                            Traceback (most recent call last):
                                              [...]
                                              File "/nix/store/xk5yksbw09p6qwk0maq2cb2in3z6f4gn-matrix-synapse-1.91.2/lib/python3.10/site-packages/synapse/media/url_previewer.py", line 398, in _is_url_blocked
                                                for attrib, pattern in entry.items():
                                            AttributeError: 'str' object has no attribute 'items'

To make sure that people aren't confused when upgrading their configs, I
decided to work with `types.coercedTo` to "pretend" accepting the old
type signature, but then throwing an error explaining what to do (and
rejecting the broken configuration).

[1] https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urlsplit
2023-09-14 17:32:26 +02:00
Nick Cao 5451e0594a
Merge pull request #253121 from NickCao/mautrix
python310Packages.mautrix: 0.20.0 -> 0.20.1
2023-09-04 18:31:36 -04:00
rnhmjoj 4fb8212162
nixos/mautrix-whatsapp: log to the journal only
Logging outside the journal requires to manually clean/rotate the logs
and is quite surprising behavior: it should not be the default.
2023-09-04 01:20:17 +02:00
rnhmjoj 5fc70937a1
nixos/mautrix-whatsapp: set default homeserver address
Without one the bridge won't start.
Note: localhost:8448 is the default listening address of matrix-synapse.
2023-09-04 01:20:17 +02:00
rnhmjoj 035f905124
nixos/mautrix-whatsapp: fix merging of default settings
This implements proper merging of user-provided values and default
values for the settings option.

Without this, the user must provide a complete configuration file, as
changing a single setting replaces the entire JSON value, rendering the
default values completely useless. In fact, the bridge won't even start
using the default settings.
2023-09-04 01:19:54 +02:00
rnhmjoj 9e0457115e
nixos/mautrix-whatsapp: use static user and group
The DynamicUser mechanism does not allow share the bridge
registration.yaml file with matrix-synapse in any easy way:

1. the mautrix-whatsapp group under which the service runs is not in
   /etc/group, so you can't add matrix-synapse to this.
   This makes the group read bit on the file useless as the group is
   effectively always empty.

2. It's not possible to use ACLs or copy the file during preStart or
   postStart because the commands are executed with low priviledges.

By using a normal (static) user/group the secret can be shared with
synapse as follows:

  services.matrix_synapse.settings.app_service_config_files =
    [ "/var/lib/mautrix-whatsapp/whatsapp-registration.yaml" ];

  users.users.matrix-synapse.extraGroups = [ "mautrix-whatsapp" ];
2023-09-04 00:40:50 +02:00
rnhmjoj e932745cb8
nixos/mautrix-whatsapp: fix docbook description
Until NixOS 23.11 is release all options must be marked as migrated from
docbook to markdown.
2023-09-03 22:22:27 +02:00
Nick Cao 69596874f1
nixos/mautrix-telegram: drop removed --base-config flag
See also: 9b67b17ac4
2023-09-03 08:59:57 -04:00
Martin Weinelt e57875a2c4
Merge pull request #248409 from CobaltCause/conduit-0.6.0
matrix-conduit: 0.5.0 -> 0.6.0
2023-08-16 16:30:08 +02:00
Maximilian Bosch a471325eaf
Merge pull request #221318 from mweinelt/synapse-extras
nixos/matrix-synapse: Allow passing extras, discover extras from config
2023-08-14 18:43:05 +02:00
Charles Hall 02fd938fb7
nixos/conduit: disable update checks by default 2023-08-10 23:16:19 -07:00
Maximilian Bosch 1ab411fcd4
Merge pull request #247386 from montchr/docs-matrix-synapse
nixos/matrix-synapse: set public baseurl in example config
2023-08-10 12:52:34 +02:00
Frédéric Christ 3a1f5757b9 mautrix-whatsapp: move defaults back to options.
As suggested by @nickcao this commit moves the defaults back to the
options. Only `homeserver.domain` stays in the config section since the
documentation module does not support referencing attributes of other
modules.
2023-08-06 11:03:17 +02:00
Chris Montgomery aefa0bb6cc
nixos/matrix-synapse: set public baseurl in example config 2023-08-05 16:08:35 -04:00
Frédéric Christ 288d2ee55d mautrix-whatsapp: Move defaults to config section
This contribution applies Example 32 (conventional settings option) from
[nixpkgs](https://nixos.org/manual/nixos/stable/#sec-settings-nix-representable).
2023-08-05 13:57:15 +02:00
Frédéric Christ 0173330426 mautrix-whatsapp: Add postgres options to example 2023-08-02 21:32:55 +02:00
Frédéric Christ b443a4d940 mautrix-whatsapp: Apply suggestions
This contribution applies suggestions made by Luflosi in
https://github.com/NixOS/nixpkgs/pull/176025#issuecomment-1237338551
as well as some general refactoring.

Co-authored-by: Luflosi <Luflosi@users.noreply.github.com>
2023-08-02 21:06:41 +02:00
Victor SENE 641d717ace nixos/mautrix-whatsapp: init module
Import from PR https://github.com/NixOS/nixpkgs/pull/176025

Co-authored-by: Luflosi <Luflosi@users.noreply.github.com>
2023-08-02 21:06:41 +02:00
Maximilian Bosch d2facca5c0
nixos/matrix-synapse: fix option description of extras option
Co-authored-by: Benjamin Saunders <ben.e.saunders@gmail.com>
2023-08-01 18:16:56 +02:00
Maximilian Bosch 701d0e1da6
nixos/matrix-synapse: fix path to extras for additive settings 2023-07-31 19:15:09 +02:00
Maximilian Bosch 190886c5cc
nixos/matrix-synapse: clarify that extras are additive 2023-07-31 18:54:17 +02:00
Maximilian Bosch 5a3870c212
nixos/matrix-synapse: expose final matrix-synapse package via package-option
When extending this module, it might be necessary to run something
from the package that's used in `matrix-synapse.service` (e.g. for
workers).

Now this can be trivially done by using
`config.services.matrix-synapse.package`. Previously it was necessary to
reuse the `PYTHONPATH` from the environment of `matrix-synapse.service`,
but that one doesn't exist anymore.
2023-07-31 18:20:28 +02:00
Дамјан Георгиевски 69bc2ad72f matrix-appservice-irc: 0.38.0 -> 1.0.1
https://github.com/matrix-org/matrix-appservice-irc/releases/tag/1.0.0

* This release drops support for Node 16. The minimum required version is now 18+.
* Moved from NPM to Yarn

https://github.com/matrix-org/matrix-appservice-irc/releases/tag/1.0.1

* Fixes for GHSA-vc7j-h8xg-fv5x.
* Fixes for GHSA-3pmj-jqqp-2mj3.
* Fixes for GHSA-c7hh-3v6c-fj4q
* Update matrix-appservice-bridge to 9.0.1

while there was an effort to make this package with `mkYarnPackage`, in the end it
was suggested to just use `stdenv.mkDerivation` instead

nixos/matrix-appservice-irc:
* fix path to config.schema.yml directory stucture of the package changed
* use remarshal instead of python and pyyaml
  to convert the config schema from yaml to json
2023-07-31 11:19:42 +02:00
Martin Weinelt 6ae8e13396
nixos/matrix-appservice-irc: update syscall filter
Simplify the SystemcallFilter by employing an explicit allow list, and
an explicit block list.

Node since version 18 requires syscalls in the @pkey group.

Excluding @privileged and @resources is a recommendation in
systemd-analyze.
2023-07-30 03:07:52 +02:00
Martin Weinelt 18733782ad
nixos/conduit: improve state directory permissions
Allow only the conduit user to access its database files, and make sure
to create all new files with 0600 (o+rw).
2023-07-25 16:54:39 +02:00
Sandro Jäckel 18010665ca
nixos/matrix-sliding-sync: init
Co-authored-by: Emily <55066419+emilylange@users.noreply.github.com>
2023-07-19 23:59:25 +02:00
Martin Weinelt 1076c3ada6
nixos/matrix-synapse: Allow passing extras, discover extras from config
With this change we allow the user to configure extras, exposed as
optional-dependencies on the matrix-synapse package.

The vertical integration between package, user configuration and
deployment is a huge boon which then allows us to dynamically adapt the
python environment the service runs in, by inspecting the configuration
and autodiscovering certain used extras from config paths.
2023-07-18 17:53:27 +02:00
chayleaf 4d4c73ff78 treewide: update path to getent 2023-07-12 02:32:23 +07:00
Frédéric Tobias Christ bb55edd515 mautrix-telegram: 0.14.0 -> 0.14.1
Add new configuration option regarding IPv6 support to the example.

Diff: https://github.com/mautrix/telegram/compare/refs/tags/v0.14.0...v0.14.1
Changelog: https://github.com/mautrix/telegram/releases/tag/v0.14.1
2023-07-02 17:44:51 +02:00
Nick Cao cf58ff13a3
Merge pull request #234254 from kevincox/mautrix-facebook-appservice-id
nixos.mautrix-facebook: Fix appservice name
2023-05-26 19:48:00 -06:00
Kevin Cox 5242aea64f
nixos.mautrix-facebook: Fix appservice name
It appears that newer mautrix-facebook versions default to the appservice name `facebook`. This was breaking our registration and causing mautrix-facebook to fail to start. This changes the name back and makes the registration generated match whatever the setting in the app is.
2023-05-26 12:39:37 -04:00
IndeedNotJames d212ec13b8
nixos/synapse: allow omitting trusted_key_servers[].verify_keys
Synapse does not require the `verify_keys` attr/object to be set.
It made sense back in the day, when federation traffic used to use self-signed certificates. But this is no longer the case.

The previous `types.nullOr` didn't actually allow omitting `verify_keys` because Synapse's config parser is unable to parse that.

Not a breaking change.

Upstream docs: https://matrix-org.github.io/synapse/latest/usage/configuration/config_documentation.html?highlight=verify_keys#trusted_key_servers
2023-05-19 15:46:53 +02:00
Nick Cao c256ecf7a3
nixos/mjolnir: explicitly set --mjolnir-config 2023-05-15 18:40:57 +08:00
Jörg Thalheim 87083d40c0
Merge pull request #221856 from Mic92/dendrite
dendrite: 0.11.0 -> 0.12.0
2023-04-05 08:36:44 +01:00
K900 542012fe24
Merge pull request #222336 from motiejus/master_synapse_signing_key_path
matrix-synapse: fix signing key path in fix-permissions script
2023-03-29 16:57:56 +03:00