From 0511e99dd47ee4ed793d9cab91688e7ebac5635c Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Sun, 25 Apr 2021 20:25:33 +0200 Subject: [PATCH] nix(refactor): Add withPath to checkedShellScript --- nix/overlays/checked-shell-script/checked-shell-script.nix | 5 +++++ nix/tools/memory.nix | 3 +-- nix/tools/tests.nix | 3 +-- nix/tools/withTools.nix | 4 ++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/nix/overlays/checked-shell-script/checked-shell-script.nix b/nix/overlays/checked-shell-script/checked-shell-script.nix index ae0af139c2..cf391e9cd1 100644 --- a/nix/overlays/checked-shell-script/checked-shell-script.nix +++ b/nix/overlays/checked-shell-script/checked-shell-script.nix @@ -18,6 +18,7 @@ , inRootDir ? false , redirectTixFiles ? true , withEnv ? null +, withPath ? [ ] , withTmpDir ? false }: text: let @@ -114,6 +115,10 @@ let export PATH="$env/bin:$PATH" '' + + lib.optionalString (lib.length withPath > 0) '' + export PATH="${lib.concatMapStrings (p: p + "/bin:") withPath}$PATH" + '' + + "(${text})" + lib.optionalString withTmpDir '' diff --git a/nix/tools/memory.nix b/nix/tools/memory.nix index 064cec8f19..6af26a5266 100644 --- a/nix/tools/memory.nix +++ b/nix/tools/memory.nix @@ -14,10 +14,9 @@ let name = "postgrest-test-memory"; docs = "Run the memory tests."; inRootDir = true; + withPath = [ postgrestProfiled curl ]; } '' - export PATH="${postgrestProfiled}/bin:${curl}/bin:$PATH" - ${withTools.latest} test/memory-tests.sh ''; diff --git a/nix/tools/tests.nix b/nix/tools/tests.nix index 1e46bb1e71..c72c75c109 100644 --- a/nix/tools/tests.nix +++ b/nix/tools/tests.nix @@ -73,10 +73,9 @@ let docs = "Dump the loaded schema's DbStructure as a yaml file."; inRootDir = true; withEnv = postgrest.env; + withPath = [ jq ]; } '' - export PATH="${jq}/bin:$PATH" - ${withTools.latest} \ ${cabal-install}/bin/cabal v2-run ${devCabalOptions} --verbose=0 -- \ postgrest --dump-schema \ diff --git a/nix/tools/withTools.nix b/nix/tools/withTools.nix index c74ce32240..1f3f2a8018 100644 --- a/nix/tools/withTools.nix +++ b/nix/tools/withTools.nix @@ -25,6 +25,7 @@ let addCommandCompletion = true; inRootDir = true; redirectTixFiles = false; + withPath = [ postgresql ]; withTmpDir = true; } '' @@ -32,8 +33,7 @@ let if test -v PGRST_DB_URI; then exec "$@" fi - - export PATH=${postgresql}/bin:"$PATH" + setuplog="$tmpdir/setup.log" log () {