-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixos/matrix-synapse: migrate to rfc42 settings and formatter #158605
Conversation
d0722fe
to
382feba
Compare
05d9fbd
to
2afbef0
Compare
there has been a related/previous attempt in #120260 as well |
2afbef0
to
7aa64df
Compare
I consider that approach superseded. It does not really reflect what RFC42 intended and there hasn't been any work on it in a while. |
7aa64df
to
976b075
Compare
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/breaking-changes-announcement-for-unstable/17574/4 |
I think I've addressed all remaining review comments. |
@ofborg test matrix-synapse matrix-appservice-irc mjolnir pantalaimon |
matrix-synapse: fix release notes and doc for #158605 changes
Has someone a good example how to generate the extraConfigFiles from sops-nix secrets? |
The
synapse will fail to start with this error:
We really need an environment file+splicing or ad hoc |
Sounds like an upstream problem with how they merge config files. Not sure we can do much about that. |
That was the case before this PR already IIRC. Also, you're free to file a patch %) |
Yes, sure, it's just that the docs now points to this option.
I will probably do so. I'm not sure what's the best way to do it, though. |
This was indeed a known issue #158605 (comment). I wish we had a standardized way to do secrethandling templating things in nixpgks since it's so common to need it |
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] NixOS#158605 (comment) [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`.
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] NixOS#158605 (comment) [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`.
Motivation for this change
Update the module to use RFC42-style settings and formatters.
Migrations looks messy, but really isn't
For the most part options can be just moved into the
settings
attribute set, so migrations should still be fairly easy. Of course a proper changelog entry will cover the migration bits.It looks a bit messy with all the
mkRemovedOptionModule
imports, but the module just advertises an enormous amount of options. I tried to usemkRenamedOptionModule
, but that is not compatible with submodules (cf. #96006).Removed options
I'm also removing a number of options that synapse doesn't even support anymore. And due to their lax config validation they never even complained about that.
Scope of advertised opotions
I'm also removing a number of options that are overly specific and expand the module beyond what the average joe would ever use. This is a freeform type now, so people can still set all the custom options they've ever dreamed of. In fact, if possible, I'd cull even more options still.
Resulting configuration
The rendered configurations of the matrix-synapse test look like this:
sqlite3
psycopg2
Scope of this PR
What I think is out of scope for this PR is:
Supersedes: #120260
Related: #144575
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)nixos/doc/manual/md-to-db.sh
to update generated release notes