This commit is contained in:
2025-03-17 12:03:12 +04:00
parent d6e8ef7aed
commit 84ac5314a4

View File

@@ -66,13 +66,14 @@ in
config ? { }, config ? { },
extra_config ? '''', extra_config ? '''',
package ? pkgs.postgresql, package ? pkgs.postgresql,
data_dir ? ".data/",
port ? 5432, port ? 5432,
listen_addresses ? "localhost", listen_addresses ? "localhost",
... ...
}: }:
let let
runtimeDir = "${runtime}/${name}"; runtimeDir = "${runtime}/${name}";
data_dir = "${runtimeDir}/data";
merged_config = merged_config =
( (
if default_config then if default_config then
@@ -127,7 +128,11 @@ in
echo echo
echo "PostgreSQL is setting up the initial database" echo "PostgreSQL is setting up the initial database"
echo echo
if [[ -z "$PGHOST" ]]; then
OLDPGHOST=""
else
OLDPGHOST="$PGHOST" OLDPGHOST="$PGHOST"
fi
PGHOST=${lib.escapeShellArg runtimeDir} PGHOST=${lib.escapeShellArg runtimeDir}
pg_ctl -D "${data_dir}" -w start -o "-c unix_socket_directories=${data_dir} -c listen_addresses= -p ${builtins.toString port}" pg_ctl -D "${data_dir}" -w start -o "-c unix_socket_directories=${data_dir} -c listen_addresses= -p ${builtins.toString port}"
pg_ctl -D "${data_dir}" -m fast -w stop pg_ctl -D "${data_dir}" -m fast -w stop