postgresql/module.nix: add postgres user with permissions

This commit is contained in:
Charlie Root 2025-03-04 21:06:31 +01:00
commit 6cb1e31986
Signed by: faukah
SSH key fingerprint: SHA256:jpYIt4Vkz1NBTQcks/N9OPTfTFxE6KF2W/rV7hrfrIw

View file

@ -6,7 +6,7 @@
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.options) mkEnableOption; inherit (lib.options) mkEnableOption;
cfg = config.modules.sytem.services.database.postgresql; cfg = config.modules.system.services.database.postgresql;
in { in {
options.modules.system.services.database.postgresql.enable = mkEnableOption "postgresql"; options.modules.system.services.database.postgresql.enable = mkEnableOption "postgresql";
@ -28,6 +28,16 @@ in {
]; ];
ensureUsers = [ ensureUsers = [
{
name = "postgres";
ensureClauses = {
superuser = true;
login = true;
createrole = true;
createdb = true;
replication = true;
};
}
{ {
name = "git"; name = "git";
ensureDBOwnership = true; ensureDBOwnership = true;
@ -35,7 +45,7 @@ in {
]; ];
settings = { settings = {
# taken from https://pgconfigurator.cybertec.at/ # taken from https://pgconfigurator.cybertec.at/
# Connectivity # Connectivity
max_connections = 100; max_connections = 100;
superuser_reserved_connections = 3; superuser_reserved_connections = 3;