feat(db-tool): expose overridable postgresql arg and PG_CONF_FILE env
Wrap db-tool, postgres-init, postgres-cleanup with lib.makeOverridable so
consumers can inject extension-enabled PostgreSQL via .override { postgresql = ...; }.
Add PG_CONF_FILE: when set, replaces script-generated postgresql.conf entirely
(runtime port and unix_socket_directories still appended/overridden).
This commit is contained in:
@@ -2,61 +2,67 @@
|
||||
let
|
||||
shell = "${dash}/bin/dash";
|
||||
|
||||
database = hectic.writeShellApplication {
|
||||
inherit shell;
|
||||
bashOptions = [
|
||||
"errexit"
|
||||
"nounset"
|
||||
];
|
||||
# SC2209: false positive — PAGER_OR_CAT=cat stores the string "cat" intentionally
|
||||
excludeShellChecks = [ "SC2209" ];
|
||||
name = "database";
|
||||
runtimeInputs = [ hectic.migrator hectic.parse-uri postgresql_17 neovim openssh coreutils gawk ];
|
||||
mkDatabase =
|
||||
{ postgresql ? postgresql_17 }:
|
||||
hectic.writeShellApplication {
|
||||
inherit shell;
|
||||
bashOptions = [
|
||||
"errexit"
|
||||
"nounset"
|
||||
];
|
||||
# SC2209: false positive — PAGER_OR_CAT=cat stores the string "cat" intentionally
|
||||
excludeShellChecks = [ "SC2209" ];
|
||||
name = "database";
|
||||
runtimeInputs = [ hectic.migrator hectic.parse-uri postgresql neovim openssh coreutils gawk ];
|
||||
|
||||
text = ''
|
||||
${builtins.readFile hectic.helpers.posix-shell.log}
|
||||
${builtins.readFile hectic.helpers.posix-shell.change_namespace}
|
||||
${builtins.readFile hectic.helpers.posix-shell.quote}
|
||||
${builtins.readFile hectic.helpers.posix-shell.pager_or_cat}
|
||||
${builtins.readFile ./database.sh}
|
||||
'';
|
||||
text = ''
|
||||
${builtins.readFile hectic.helpers.posix-shell.log}
|
||||
${builtins.readFile hectic.helpers.posix-shell.change_namespace}
|
||||
${builtins.readFile hectic.helpers.posix-shell.quote}
|
||||
${builtins.readFile hectic.helpers.posix-shell.pager_or_cat}
|
||||
${builtins.readFile ./database.sh}
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "PostgreSQL development database management";
|
||||
mainProgram = "database";
|
||||
meta = {
|
||||
description = "PostgreSQL development database management";
|
||||
mainProgram = "database";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
postgresInit = hectic.writeShellApplication {
|
||||
inherit shell;
|
||||
bashOptions = [ ];
|
||||
name = "postgres-init";
|
||||
runtimeInputs = [ postgresql_17 coreutils ];
|
||||
mkPostgresInit =
|
||||
{ postgresql ? postgresql_17 }:
|
||||
hectic.writeShellApplication {
|
||||
inherit shell;
|
||||
bashOptions = [ ];
|
||||
name = "postgres-init";
|
||||
runtimeInputs = [ postgresql coreutils ];
|
||||
|
||||
text = builtins.readFile ./postgres-init.sh;
|
||||
text = builtins.readFile ./postgres-init.sh;
|
||||
|
||||
meta = {
|
||||
description = "Initialize local PostgreSQL instance";
|
||||
mainProgram = "postgres-init";
|
||||
meta = {
|
||||
description = "Initialize local PostgreSQL instance";
|
||||
mainProgram = "postgres-init";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
postgresCleanup = hectic.writeShellApplication {
|
||||
inherit shell;
|
||||
bashOptions = [ ];
|
||||
name = "postgres-cleanup";
|
||||
runtimeInputs = [ postgresql_17 coreutils ];
|
||||
mkPostgresCleanup =
|
||||
{ postgresql ? postgresql_17 }:
|
||||
hectic.writeShellApplication {
|
||||
inherit shell;
|
||||
bashOptions = [ ];
|
||||
name = "postgres-cleanup";
|
||||
runtimeInputs = [ postgresql coreutils ];
|
||||
|
||||
text = builtins.readFile ./postgres-cleanup.sh;
|
||||
text = builtins.readFile ./postgres-cleanup.sh;
|
||||
|
||||
meta = {
|
||||
description = "Clean up local PostgreSQL instance";
|
||||
mainProgram = "postgres-cleanup";
|
||||
meta = {
|
||||
description = "Clean up local PostgreSQL instance";
|
||||
mainProgram = "postgres-cleanup";
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
"db-tool" = database;
|
||||
"postgres-init" = postgresInit;
|
||||
"postgres-cleanup" = postgresCleanup;
|
||||
"db-tool" = lib.makeOverridable mkDatabase { };
|
||||
"postgres-init" = lib.makeOverridable mkPostgresInit { };
|
||||
"postgres-cleanup" = lib.makeOverridable mkPostgresCleanup { };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user