{ config, lib, ... }: let cfg = config.modules.services.postgresql; in { options.modules.services.postgresql = { enable = lib.mkOption { default = false; example = true; }; }; config = lib.mkIf cfg.enable { services.postgresql = { enable = true; initdbArgs = [ "--allow-group-access" "--encoding=UTF8" "--locale=C" ]; settings = { log_connections = true; log_disconnections = true; log_destination = lib.mkForce "syslog"; }; }; services.borgmatic.settings = { postgresql_databases = [ { name = "all"; } ]; }; }; }