1
0
Fork 0

add debug option for postgresql

This commit is contained in:
ibizaman 2023-11-14 00:16:29 -08:00
parent 62872a1fc1
commit 0c399bb835

View file

@ -4,6 +4,16 @@ let
in in
{ {
options.shb.postgresql = { options.shb.postgresql = {
debug = lib.mkOption {
type = lib.types.bool;
description = lib.mdDocs ''
Enable debugging options.
Currently enables shared_preload_libraries = "auto_explain, pg_stat_statements"
See https://www.postgresql.org/docs/current/pgstatstatements.html'';
default = false;
};
tcpIPPort = lib.mkOption { tcpIPPort = lib.mkOption {
type = lib.types.nullOr lib.types.port; type = lib.types.nullOr lib.types.port;
description = "Enable TCP/IP connection on given port."; description = "Enable TCP/IP connection on given port.";
@ -86,12 +96,17 @@ in
if (builtins.length cfgsWithPasswords) == 0 then "" else if (builtins.length cfgsWithPasswords) == 0 then "" else
prefix + (lib.concatStrings (map exec cfgsWithPasswords)) + suffix; prefix + (lib.concatStrings (map exec cfgsWithPasswords)) + suffix;
}; };
debugConfig = enableDebug: lib.mkIf enableDebug {
services.postgresql.settings.shared_preload_libraries = "auto_explain, pg_stat_statements";
};
in in
lib.mkMerge ( lib.mkMerge (
[ [
(dbConfig cfg.passwords) (dbConfig cfg.passwords)
(pwdConfig cfg.passwords) (pwdConfig cfg.passwords)
(lib.mkIf (!(isNull cfg.tcpIPPort)) (tcpConfig cfg.tcpIPPort)) (lib.mkIf (!(isNull cfg.tcpIPPort)) (tcpConfig cfg.tcpIPPort))
(debugConfig cfg.debug)
] ]
); );
} }