nixos-module: do explicit postgres init

This commit is contained in:
Astro 2023-08-09 00:06:34 +02:00
parent fb01b07b1d
commit cda567d0bc
1 changed files with 3 additions and 8 deletions

View File

@ -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};
'';
};