2024-12-02 21:12:45 +03:00
|
|
|
{
|
2024-12-18 09:40:11 +03:00
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
{
|
|
|
|
services.postgresql =
|
|
|
|
let
|
|
|
|
# Populate with services here.
|
|
|
|
configurations = [
|
|
|
|
"forgejo"
|
|
|
|
"invidious"
|
|
|
|
"mattermost"
|
|
|
|
"nextcloud"
|
|
|
|
"paperless"
|
|
|
|
"privatebin"
|
|
|
|
];
|
2024-12-02 21:12:45 +03:00
|
|
|
|
2024-12-18 09:40:11 +03:00
|
|
|
ensureDatabases = [ "root" ] ++ configurations;
|
2024-12-02 21:12:45 +03:00
|
|
|
|
2024-12-18 09:40:11 +03:00
|
|
|
ensureUsers = map (name: {
|
|
|
|
inherit name;
|
|
|
|
ensureDBOwnership = true;
|
|
|
|
ensureClauses =
|
|
|
|
if name == "root" then
|
|
|
|
{
|
|
|
|
createdb = true;
|
|
|
|
createrole = true;
|
|
|
|
superuser = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ };
|
|
|
|
}) ensureDatabases;
|
2024-12-02 21:12:45 +03:00
|
|
|
|
2024-12-18 09:40:11 +03:00
|
|
|
authentication = "local all all trust";
|
|
|
|
in
|
|
|
|
{
|
|
|
|
inherit authentication ensureDatabases ensureUsers;
|
2024-12-02 21:12:45 +03:00
|
|
|
|
2024-12-18 09:40:11 +03:00
|
|
|
enable = true;
|
|
|
|
dataDir = "/var/lib/postgresql/14";
|
|
|
|
package = pkgs.postgresql_14;
|
2024-12-02 21:12:45 +03:00
|
|
|
|
2024-12-18 09:40:11 +03:00
|
|
|
# NOTE: Debug mode.
|
|
|
|
# settings = {
|
|
|
|
# log_connections = true;
|
|
|
|
# log_destination = lib.mkForce "syslog";
|
|
|
|
# log_disconnections = true;
|
|
|
|
# log_statement = "all";
|
|
|
|
# logging_collector = true;
|
|
|
|
# };
|
|
|
|
};
|
2024-12-02 21:12:45 +03:00
|
|
|
}
|