hosts/plover: update PostgreSQL initial script

We're doing the secure schema usage pattern as recommended from the
documentation. Since it is an initial script that will only run once, I
think it is OK to override steps such as creating roles ahead.
This commit is contained in:
Gabriel Arazas 2022-12-12 14:17:57 +08:00
parent 604cbbd48f
commit 4190b4a481

View File

@ -161,14 +161,17 @@ in
# feature). # feature).
initialScript = initialScript =
let let
# This will be run once anyways so it is acceptable to create users
# "forcibly".
perUserSchemas = lib.lists.map perUserSchemas = lib.lists.map
(user: "CREATE SCHEMA ${user.name};") (user: ''
CREATE USER ${user.name};
CREATE SCHEMA ${user.name} AUTHORIZATION ${user.name};
'')
config.services.postgresql.ensureUsers; config.services.postgresql.ensureUsers;
script = pkgs.writeText "plover-initial-postgresql-script" '' in pkgs.writeText "plover-initial-postgresql-script" ''
${lib.concatStringsSep "\n" perUserSchemas} ${lib.concatStringsSep "\n" perUserSchemas}
''; '';
in
script;
settings = { settings = {
log_connections = true; log_connections = true;