nix: override PGRST_CMD for postgrest-loadtest from env

Enables `PGRST_CMD=postgrest-profiled-run postgrest-loadtest` running
loadtest against profiled executable, which wasn't available before
This commit is contained in:
Andrei Dziahel
2025-11-25 19:46:23 +00:00
committed by GitHub
parent 802cce9a28
commit 6d462f762e
+18 -15
View File
@@ -361,6 +361,7 @@ let
"ARG_POSITIONAL_SINGLE([command], [Command to run])" "ARG_POSITIONAL_SINGLE([command], [Command to run])"
"ARG_LEFTOVERS([command arguments])" "ARG_LEFTOVERS([command arguments])"
"ARG_OPTIONAL_SINGLE([monitor], [m], [Enable CPU and memory monitoring of the PostgREST process and output to the designated file as markdown])" "ARG_OPTIONAL_SINGLE([monitor], [m], [Enable CPU and memory monitoring of the PostgREST process and output to the designated file as markdown])"
"ARG_USE_ENV([PGRST_CMD], [], [PostgREST executable to run])"
]; ];
positionalCompletion = "_command"; positionalCompletion = "_command";
workingDir = "/"; workingDir = "/";
@@ -370,22 +371,24 @@ let
'' ''
export PGRST_SERVER_UNIX_SOCKET="$tmpdir"/postgrest.socket export PGRST_SERVER_UNIX_SOCKET="$tmpdir"/postgrest.socket
rm -f result if [ -z "''${PGRST_CMD:-}" ]; then
if [ -z "''${PGRST_BUILD_CABAL:-}" ]; then rm -f result
echo -n "Building postgrest (nix)... " if [ -z "''${PGRST_BUILD_CABAL:-}" ]; then
# Using lib.getBin to also make this work with older checkouts, where .bin was not a thing, yet. echo -n "Building postgrest (nix)... "
nix-build -E 'with import ./. {}; pkgs.lib.getBin postgrestPackage' > "$tmpdir"/build.log 2>&1 || { # Using lib.getBin to also make this work with older checkouts, where .bin was not a thing, yet.
echo "failed, output:" nix-build -E 'with import ./. {}; pkgs.lib.getBin postgrestPackage' > "$tmpdir"/build.log 2>&1 || {
cat "$tmpdir"/build.log echo "failed, output:"
exit 1 cat "$tmpdir"/build.log
} exit 1
PGRST_CMD=$(echo ./result*/bin/postgrest) }
else PGRST_CMD=$(echo ./result*/bin/postgrest)
echo -n "Building postgrest (cabal)... " else
postgrest-build echo -n "Building postgrest (cabal)... "
PGRST_CMD=postgrest-run postgrest-build
PGRST_CMD=postgrest-run
fi
echo "done."
fi fi
echo "done."
ver=$($PGRST_CMD ${legacyConfig} --version) ver=$($PGRST_CMD ${legacyConfig} --version)