dots/hosts/luna/modules/services/postgresql.nix

44 lines
917 B
Nix
Raw Permalink Normal View History

{ config, pkgs, ... }:
let
pg_dataDir_base = "/var/lib/postgresql";
in
2024-05-03 14:35:00 -05:00
{
services.postgresqlBackup = {
enable = true;
2024-05-03 14:35:00 -05:00
location = "/var/backup/postgresql";
backupAll = true;
};
2024-05-03 14:35:00 -05:00
services.postgresql = {
enable = true;
dataDir = "${pg_dataDir_base}/${config.services.postgresql.package.psqlSchema}";
2024-05-03 14:35:00 -05:00
settings = {
log_connections = true;
log_disconnections = true;
logging_collector = true;
log_statement = "all";
};
ensureUsers = [
{
name = "root";
ensureClauses.superuser = true;
}
];
};
environment.systemPackages = [ pkgs.pgloader ];
environment.persistence.save.directories = [
{
directory = "${pg_dataDir_base}";
2024-05-03 14:35:00 -05:00
user = "postgres";
group = "postgres";
}
{
directory = config.services.postgresqlBackup.location;
user = "postgres";
group = "postgres";
}
];
}