server-configs/shared/applications/state/postgresql.nix
2024-08-24 21:36:56 +02:00

20 lines
702 B
Nix

{ config, ... }:
let
stateDir= config.mine.zfsMounts."rpool/safe/svcs/postgresql";
backupDir = config.mine.zfsMounts."rpool/backup/postgresql";
postgresql_user = config.systemd.services.postgresql.serviceConfig.User;
postgresql_group = config.systemd.services.postgresql.serviceConfig.Group;
in {
services.postgresql.dataDir = stateDir;
# backup postgresql databases (everything in ensuredatabases)
services.postgresqlBackup.location = backupDir;
# ensure correct permissions for postgresql and postgresql backup
systemd.tmpfiles.rules = [
"Z ${stateDir} 0700 ${postgresql_user} ${postgresql_group} -"
"Z ${backupDir} 0700 ${postgresql_user} ${postgresql_group} -"
];
}