harden devshell: anchor pgdata to repo root, broaden gitignore

shellHook now derives PGDATA from $(git rev-parse --show-toplevel)
instead of $PWD. nix develop / direnv from a subdir (e.g.
backend/) used to seed a duplicate cluster at backend/.postgres
that leaked into git tracking. .gitignore loses its leading slash
on .postgres/ + .direnv/ + .pc.* so any nested cluster also gets
ignored. fallback to pwd preserves behavior outside a git repo.

968 stray backend/.postgres/* blobs already pruned from history
via git-filter-repo before this commit.
This commit is contained in:
yisroel 2026-05-06 14:58:27 +03:00
parent 0178654535
commit ee1b30d0ec
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
2 changed files with 8 additions and 4 deletions

6
.gitignore vendored
View file

@ -1,9 +1,9 @@
# Nix devshell artefacts # Nix devshell artefacts
/.postgres/ .postgres/
/.direnv/ .direnv/
result result
result-* result-*
# Process-compose state # Process-compose state
/.pc.* .pc.*
process-compose-*.log process-compose-*.log

View file

@ -27,7 +27,11 @@
]; ];
shellHook = '' shellHook = ''
export PGDATA="$PWD/.postgres" # Anchor PGDATA to the repo root so subshells in subdirs
# (e.g. backend/) reuse the same cluster instead of seeding
# a stray .postgres there.
REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
export PGDATA="$REPO_ROOT/.postgres"
export PGHOST="$PGDATA" export PGHOST="$PGDATA"
export PGUSER="postgres" export PGUSER="postgres"
export PGDATABASE="postgres" export PGDATABASE="postgres"