63 lines
1.5 KiB
Nix
63 lines
1.5 KiB
Nix
|
{
|
||
|
config,
|
||
|
lib,
|
||
|
pkgs,
|
||
|
...
|
||
|
}:
|
||
|
|
||
|
# sudo -u postgres vacuumdb --all --analyze-in-stages
|
||
|
# /var/lib/postgresql/16/delete_old_cluster.sh
|
||
|
let
|
||
|
vars = import ./vars.nix;
|
||
|
dataDir = "${vars.primary_db}/postgresql/nix/${config.services.postgresql.package.psqlSchema}";
|
||
|
backupLocation = "${vars.primary_db}/postgresql/nix_backups";
|
||
|
in
|
||
|
{
|
||
|
services = {
|
||
|
postgresql = {
|
||
|
inherit dataDir;
|
||
|
enable = true;
|
||
|
enableJIT = true;
|
||
|
package = pkgs.postgresql_16;
|
||
|
identMap = ''
|
||
|
# ArbitraryMapName systemUser DBUser
|
||
|
superuser_map root postgres
|
||
|
superuser_map alice postgres
|
||
|
# Let other names login as themselves
|
||
|
superuser_map /^(.*)$ \1
|
||
|
'';
|
||
|
|
||
|
# initialScript = config.sops.secrets."postgres/init".path;
|
||
|
ensureDatabases = [ "atticd" ];
|
||
|
ensureUsers = [
|
||
|
{
|
||
|
name = "atticd";
|
||
|
ensureDBOwnership = true;
|
||
|
}
|
||
|
];
|
||
|
|
||
|
refreshCollation = true;
|
||
|
vacuumAnalyzeTimer.enable = true;
|
||
|
upgrade = {
|
||
|
enable = true;
|
||
|
stopServices = [
|
||
|
"hydra-evaluator"
|
||
|
"hydra-init"
|
||
|
"hydra-notify"
|
||
|
"hydra-queue-runner"
|
||
|
"hydra-send-stats"
|
||
|
"hydra-server"
|
||
|
"atticd"
|
||
|
];
|
||
|
};
|
||
|
};
|
||
|
postgresqlBackup = {
|
||
|
enable = true;
|
||
|
compression = "zstd";
|
||
|
compressionLevel = 19;
|
||
|
pgdumpOptions = "--create --clean";
|
||
|
location = backupLocation;
|
||
|
};
|
||
|
};
|
||
|
}
|