diff --git a/nixos/modules/services/misc/matrix-synapse.xml b/nixos/modules/services/misc/matrix-synapse.xml
index 053a3b2a563fc..2f2ac27eeb9d0 100644
--- a/nixos/modules/services/misc/matrix-synapse.xml
+++ b/nixos/modules/services/misc/matrix-synapse.xml
@@ -33,6 +33,7 @@
installation instructions of Synapse .
+{ pkgs, ... }:
let
fqdn =
let
@@ -46,7 +47,7 @@ in {
networking.firewall.allowedTCPPorts = [ 80 443 ];
services.postgresql.enable = true;
- services.postgresql.initialScript = ''
+ 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