Skip to content

Commit 6d462f7

Browse files
authored
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
1 parent 802cce9 commit 6d462f7

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

nix/tools/withTools.nix

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ let
361361
"ARG_POSITIONAL_SINGLE([command], [Command to run])"
362362
"ARG_LEFTOVERS([command arguments])"
363363
"ARG_OPTIONAL_SINGLE([monitor], [m], [Enable CPU and memory monitoring of the PostgREST process and output to the designated file as markdown])"
364+
"ARG_USE_ENV([PGRST_CMD], [], [PostgREST executable to run])"
364365
];
365366
positionalCompletion = "_command";
366367
workingDir = "/";
@@ -370,22 +371,24 @@ let
370371
''
371372
export PGRST_SERVER_UNIX_SOCKET="$tmpdir"/postgrest.socket
372373
373-
rm -f result
374-
if [ -z "''${PGRST_BUILD_CABAL:-}" ]; then
375-
echo -n "Building postgrest (nix)... "
376-
# Using lib.getBin to also make this work with older checkouts, where .bin was not a thing, yet.
377-
nix-build -E 'with import ./. {}; pkgs.lib.getBin postgrestPackage' > "$tmpdir"/build.log 2>&1 || {
378-
echo "failed, output:"
379-
cat "$tmpdir"/build.log
380-
exit 1
381-
}
382-
PGRST_CMD=$(echo ./result*/bin/postgrest)
383-
else
384-
echo -n "Building postgrest (cabal)... "
385-
postgrest-build
386-
PGRST_CMD=postgrest-run
374+
if [ -z "''${PGRST_CMD:-}" ]; then
375+
rm -f result
376+
if [ -z "''${PGRST_BUILD_CABAL:-}" ]; then
377+
echo -n "Building postgrest (nix)... "
378+
# Using lib.getBin to also make this work with older checkouts, where .bin was not a thing, yet.
379+
nix-build -E 'with import ./. {}; pkgs.lib.getBin postgrestPackage' > "$tmpdir"/build.log 2>&1 || {
380+
echo "failed, output:"
381+
cat "$tmpdir"/build.log
382+
exit 1
383+
}
384+
PGRST_CMD=$(echo ./result*/bin/postgrest)
385+
else
386+
echo -n "Building postgrest (cabal)... "
387+
postgrest-build
388+
PGRST_CMD=postgrest-run
389+
fi
390+
echo "done."
387391
fi
388-
echo "done."
389392
390393
ver=$($PGRST_CMD ${legacyConfig} --version)
391394

0 commit comments

Comments
 (0)