postgres ensure socketDir mktemp init succeeds (#81)

* fix: ensure socketDir mktemp succeeds when path does not exist yet

* postgres: test socketDir with a multi-level non-existing path
This commit is contained in:
John A. Lotoski 2024-01-19 12:50:08 -06:00 committed by GitHub
parent 1a3f2d1936
commit eb8361b9ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 2 deletions

View File

@ -7,6 +7,7 @@
};
services.postgres."pg2" = {
enable = true;
socketDir = "./test/new/socket/path";
port = 5433;
listen_addresses = "127.0.0.1";
# INFO: pg1 creates $USER database while pg2 doesn't because `initialDatabases` is present
@ -29,7 +30,7 @@
text = ''
echo 'SELECT version();' | psql -h 127.0.0.1
echo 'SHOW hba_file;' | psql -h 127.0.0.1 | ${pkgs.gawk}/bin/awk 'NR==3' | grep '^ /nix/store'
# initialScript.before test
echo "SELECT 1 FROM pg_roles WHERE rolname = 'bar';" | psql -h 127.0.0.1 | grep -q 1

View File

@ -100,7 +100,7 @@ in
echo
echo "PostgreSQL is setting up the initial database."
echo
PGHOST=$(mktemp -d "$(readlink -f "${config.socketDir}")/pg-init-XXXXXX")
PGHOST=$(mkdir -p "${config.socketDir}" && mktemp -d "$(readlink -f "${config.socketDir}")/pg-init-XXXXXX")
export PGHOST
function remove_tmp_pg_init_sock_dir() {