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 = {