Skip to content

Commit

Permalink
nixos/matrix-synapse: don't use services.postgresql.initialScript i…
Browse files Browse the repository at this point in the history
…n setup example

Closes NixOS#285688

This is misleading because `initialScript` will only be executed at the
*very first* run of postgresql. I.e. when deploying synapse to a server
with an existing postgresql, this won't work.

We don't have a good way of automatically provisioning databases
_declaratively_, so for now just explain what needs to be done here and
leave it to the user how to include this into their deployment.
  • Loading branch information
Ma27 committed Apr 10, 2024
1 parent ce4a55c commit a3d3cdf
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions nixos/modules/services/matrix/synapse.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,27 @@ around Matrix.

[Synapse](https://github.com/element-hq/synapse) is
the reference homeserver implementation of Matrix from the core development
team at matrix.org. The following configuration example will set up a
team at matrix.org.

Before deploying synapse server, a postgresql database must be set up.
For that, please make sure that postgresql is running and the following
SQL statements to create a user & database called `matrix-synapse` were
executed before synapse starts up:

```sql
CREATE ROLE "matrix-synapse";
CREATE DATABASE "matrix-synapse" WITH OWNER "matrix-synapse"
TEMPLATE template0
LC_COLLATE = "C"
LC_CTYPE = "C";
```

Usually, it's sufficient to do this once manually before
continuing with the installation.

Please make sure to set a different password.

The following configuration example will set up a
synapse server for the `example.org` domain, served from
the host `myhostname.example.org`. For more information,
please refer to the
Expand All @@ -41,13 +61,6 @@ in {
networking.firewall.allowedTCPPorts = [ 80 443 ];
services.postgresql.enable = true;
services.postgresql.initialScript = pkgs.writeText "synapse-init.sql" ''
CREATE ROLE "matrix-synapse" WITH LOGIN PASSWORD 'synapse';
CREATE DATABASE "matrix-synapse" WITH OWNER "matrix-synapse"
TEMPLATE template0
LC_COLLATE = "C"
LC_CTYPE = "C";
'';
services.nginx = {
enable = true;
Expand Down

0 comments on commit a3d3cdf

Please sign in to comment.