nixpkgs/nixos/modules/services/matrix
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
..
appservice-discord.nix nixos/appservice-discord: customizable package 2023-02-11 01:08:46 +08:00
appservice-irc.nix matrix-appservice-irc: 0.38.0 -> 1.0.1 2023-07-31 11:19:42 +02:00
conduit.nix nixos/conduit: disable update checks by default 2023-08-10 23:16:19 -07:00
dendrite.nix dendrite: 0.11.0 -> 0.12.0 2023-03-18 15:35:47 +01:00
matrix-sliding-sync.nix nixos/matrix-sliding-sync: init 2023-07-19 23:59:25 +02:00
mautrix-facebook.nix nixos.mautrix-facebook: Fix appservice name 2023-05-26 12:39:37 -04:00
mautrix-telegram.nix nixos/mautrix-telegram: drop removed --base-config flag 2023-09-03 08:59:57 -04:00
mautrix-whatsapp.nix nixos/mautrix-whatsapp: log to the journal only 2023-09-04 01:20:17 +02:00
mjolnir.md nixos/mjolnir: convert manual chapter to MD 2023-01-10 10:31:56 +01:00
mjolnir.nix nixos/mjolnir: explicitly set --mjolnir-config 2023-05-15 18:40:57 +08:00
mx-puppet-discord.nix nixos/mx-puppet-discord: move into matrix category 2023-01-16 06:23:25 +00:00
pantalaimon-options.nix nixos/*: automatically convert option docs 2022-08-06 20:39:12 +02:00
pantalaimon.nix nixos/*: automatically convert option docs 2022-08-06 20:39:12 +02:00
synapse.md nixos/matrix-synapse: set public baseurl in example config 2023-08-05 16:08:35 -04:00
synapse.nix nixos/matrix-synapse: refactor assertions for missing listener resources 2023-09-20 15:48:03 +02:00