From d6963248aefe1801c04912cc685b95f2fbc5b1ee Mon Sep 17 00:00:00 2001 From: Craige McWhirter Date: Tue, 4 Aug 2020 07:32:42 +1000 Subject: [PATCH] Corrected postgres setting for matrix-synapse --- roles/matrix.nix | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/roles/matrix.nix b/roles/matrix.nix index 9b38845..7727fb6 100644 --- a/roles/matrix.nix +++ b/roles/matrix.nix @@ -8,6 +8,13 @@ ../secrets/matrix.nix ]; + i18n = { + extraLocaleSettings = { + LC_COLLATE = "C"; # Ensure correct locale for postgres + LC_CTYPE = "C"; # Ensure correct locale for postgres + }; + }; + services = { matrix-synapse = { @@ -22,7 +29,7 @@ resources = [ { compress = true; - names = [ "client" "webclient" ]; + names = [ "client" ]; } { compress = false; names = [ "federation" ]; @@ -100,22 +107,27 @@ postgresql = { enable = true; + ensureDatabases = [ "matrix-synapse" ]; # Ensure the database persists + ensureUsers = [ + { + name = "matrix-synapse"; # Ensure the database user persists + ensurePermissions = { # Ensure the database permissions persist + "DATABASE \"matrix-synapse\"" = "ALL PRIVILEGES"; + "ALL TABLES IN SCHEMA public" = "ALL PRIVILEGES"; + }; + } + ]; + # Initial database creation + 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.postgresql = { - ensureDatabases = [ "matrix-synapse" ]; # Ensure the database persists - ensureUsers = [ - { - name = "matrix-synapse"; # Ensure the database user persists - ensurePermissions = { # Ensure the database permissions persist - #"DATABASE \"matrix-synapse\"" = "ALL PRIVILEGES"; - #"ALL TABLES IN SCHEMA public" = "ALL PRIVILEGES"; - }; - } - ]; - }; - security.acme = { acceptTerms = true; certs = {