commit 36cd13eaae5cc864fe98f0759c37d89b0fbb73e8
parent dd7f5262d899ad484ef54a6dc8ffac818c720ec4
Author: Özgür Kesim <oec@codeblau.de>
Date: Mon, 12 Oct 2026 14:37:06 +0200
[flake] dev shell: relocatable rpath, private postgres on unix socket
Diffstat:
| M | flake.nix | | | 30 | +++++++++++++++++++----------- |
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/flake.nix b/flake.nix
@@ -115,18 +115,26 @@
echo "taler-exchange environment loaded."
export CC=gcc
export CFLAGS="-O"
- mkdir -p default
- export PGHOST=localhost
- export PGPORT=5432
- export PGUSER=$USER
- export PGDATABASE=talercheck
- export PGDATA="$PWD/default/.pg"
- echo $PWD
- [ ! -d $PGDATA ] && PGHOST="$PGDATA" pg_ctl initdb -o "-U $PGUSER"
+ # Installed binaries find our libs relative to themselves,
+ # whatever the meson --prefix is (the nix ld-wrapper does not
+ # add the prefix to their RUNPATH): $ORIGIN/../lib/ for bin/
+ # and lib/, $ORIGIN/../ for the plugins in lib/taler-exchange/.
+ # The trailing slashes keep meson install from stripping them
+ # as its own build-tree rpaths ($ORIGIN/../lib is src/lib).
+ export LDFLAGS='-Wl,-rpath,$ORIGIN/../lib/:$ORIGIN/../'
- pg_ctl -o "-p $PGPORT -k $PGDATA" start && createdb talercheck && {
- trap 'pg_ctl stop && rm -r $PGDATA' EXIT
- }
+ # Private PostgreSQL for the tests, reachable only via the
+ # Unix socket in $PGDATA. It keeps running after the shell
+ # exits and is reused by the next one; stop it with `pg_ctl stop`.
+ export PGDATA="$PWD/default/.pg"
+ export PGHOST="$PGDATA"
+ export PGUSER="$(id -un)"
+ export PGDATABASE=talercheck
+ [ -d "$PGDATA" ] || initdb > /dev/null
+ pg_ctl status > /dev/null ||
+ pg_ctl -w -l "$PWD/default/postgres.log" -o "-h ''' -k $PGDATA" start > /dev/null
+ psql -XAt -d postgres -c "SELECT 1 FROM pg_database WHERE datname = 'talercheck'" |
+ grep -qx 1 || createdb talercheck
'';
};
});