nix-configs/modules/services/postgres.nix
2025-07-29 03:02:25 +02:00

39 lines
968 B
Nix

{
pkgs,
lib,
config,
...
}:
let
cfg = config.xyno.services.postgres;
in
{
options.xyno.services.postgres.enable = lib.mkEnableOption "enables postgres";
config = lib.mkIf cfg.enable {
services.postgresql = {
enable = true;
package = pkgs.postgresql_17_jit;
identMap = ''
# ArbitraryMapName systemUser DBUser
superuser_map root postgres
superuser_map postgres postgres
# Let other names login as themselves
superuser_map /^(.*)$ \1
'';
};
services.prometheus.exporters.postgres = lib.mkIf config.xyno.services.monitoring.enable {
enable = true;
listenAddress = config.xyno.services.monitoring.ip;
port = 9187;
};
xyno.impermanence.extraDirectories = [ "/var/lib/postgresql" ];
services.borgmatic.settings.postgresql_databases = [
{
name = "all"; # gets run as root anyways so can log in
}
];
};
}