From cda567d0bcc4e7225f1ec96ebd2ca262811a7ca8 Mon Sep 17 00:00:00 2001 From: Astro Date: Wed, 9 Aug 2023 00:06:34 +0200 Subject: [PATCH] nixos-module: do explicit postgres init --- nixos-module.nix | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/nixos-module.nix b/nixos-module.nix index f38b1d1..358beb4 100644 --- a/nixos-module.nix +++ b/nixos-module.nix @@ -151,15 +151,10 @@ in }; services.postgresql = { enable = true; - ensureDatabases = [ "caveman" ]; - ensureUsers = [ { - name = dbUser; - ensurePermissions = { - "DATABASE caveman" = "ALL PRIVILEGES"; - }; - } ]; initialScript = pkgs.writeScript "initScript" '' - ALTER USER ${dbUser} WITH PASSWORD '${dbPassword}'; + CREATE ROLE ${dbUser} LOGIN PASSWORD '${dbPassword}'; + CREATE DATABASE caveman TEMPLATE template0 ENCODING UTF8; + GRANT ALL PRIVILEGES ON DATABASE caveman TO ${dbUser}; ''; };