nixpkgs/nixos/modules
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
..
config nixos/user-groups: fixup of 5666a378 2023-09-13 11:44:19 +02:00
hardware nixos/nvidia: don't assume x11 is used.. 2023-09-14 18:19:15 +02:00
i18n/input-method uim: remove qt4, fix qt5 2023-09-04 13:54:50 +02:00
image modules/image/repart: Fix stripNixStorePrefix 2023-08-22 13:09:03 +02:00
installer nixos/iso-image: Remove leftover false dichotomy between console/serial 2023-09-06 14:10:09 -04:00
misc nixos/doc: Improve documentation of documentation 2023-08-12 22:28:04 +03:00
profiles nixos/installation-device: allow nix-copy for root/nixos user 2023-08-07 16:48:49 +02:00
programs nixos/environment: drop MOZ_PLUGIN_PATH 2023-09-15 09:49:19 -04:00
security nixos/acme: rename option credentialsFile to environmentFile 2023-09-11 16:34:20 +00:00
services nixos/matrix-synapse: refactor assertions for missing listener resources 2023-09-20 15:48:03 +02:00
system Merge pull request #254918 from RaitoBezarius/dnssec-resolved 2023-09-19 06:45:07 +03:00
tasks nixos/swraid: only warn if swraid was explicitly enabled (#255426) 2023-09-16 12:19:19 +02:00
testing Merge pull request #219106 from m-bdf/nixos-testing-increase-device-timeout 2023-06-20 11:48:45 +02:00
virtualisation fix capitalization (#254542) 2023-09-15 09:59:11 +02:00
module-list.nix nixos/frp: init 2023-09-17 14:37:19 +08:00
rename.nix nodePackages.tedicross: drop 2023-09-13 15:00:38 -07:00