sourcehut: fix postgresql database permission for postgresql >= 15

Signed-off-by: Christoph Heiss <christoph@c8h4.io>
This commit is contained in:
Christoph Heiss 2023-11-11 15:50:16 +01:00
parent 66b86f8a2e
commit 88a3d2a0b4
No known key found for this signature in database
GPG Key ID: 73D5E7FDEE3DE49A

View File

@ -377,6 +377,20 @@ in
}
extraService
])) extraServices)
# Work around 'pq: permission denied for schema public' with postgres v15, until a
# solution for `services.postgresql.ensureUsers` is found.
# See https://github.com/NixOS/nixpkgs/issues/216989
# Workaround taken from nixos/forgejo: https://github.com/NixOS/nixpkgs/pull/262741
(lib.mkIf (
cfg.postgresql.enable
&& lib.strings.versionAtLeast config.services.postgresql.package.version "15.0"
) {
postgresql.postStart = (lib.mkAfter ''
$PSQL -tAc 'ALTER DATABASE "${srvCfg.postgresql.database}" OWNER TO "${srvCfg.user}";'
'');
}
)
];
systemd.timers = mapAttrs (timerName: timer: