{ 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} -" ]; }