build(faust): auto re-exec under nix-shell when faust is missing
If faust isn't in PATH but nix-shell is, transparently re-exec the script via `nix-shell -p faust --run` instead of erroring out with a hint. NISPS_BUILD_IN_NIX_SHELL guards against infinite recursion if the shell somehow still lacks faust.
This commit is contained in:
parent
2993328859
commit
0de64463fd
1 changed files with 13 additions and 1 deletions
|
|
@ -24,10 +24,22 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|||
# ---------------------------------------------------------------------------
|
||||
# Dependency checks
|
||||
# ---------------------------------------------------------------------------
|
||||
#
|
||||
# If faust isn't in PATH, automatically re-exec under `nix-shell -p faust`
|
||||
# when nix-shell is available. NISPS_BUILD_IN_NIX_SHELL prevents infinite
|
||||
# recursion if the nix-shell environment somehow still lacks faust.
|
||||
|
||||
if ! command -v faust &>/dev/null; then
|
||||
if [ "${NISPS_BUILD_IN_NIX_SHELL:-0}" = "1" ]; then
|
||||
echo "ERROR: 'faust' still not found inside nix-shell. Check your nixpkgs channel."
|
||||
exit 1
|
||||
fi
|
||||
if command -v nix-shell &>/dev/null; then
|
||||
echo "faust not in PATH — re-exec under nix-shell -p faust ..."
|
||||
exec env NISPS_BUILD_IN_NIX_SHELL=1 nix-shell -p faust --run "\"$0\" $*"
|
||||
fi
|
||||
echo ""
|
||||
echo "ERROR: 'faust' not found in PATH."
|
||||
echo "ERROR: 'faust' not found in PATH (and nix-shell is unavailable)."
|
||||
echo ""
|
||||
echo "Install options:"
|
||||
echo " nix-shell -p faust # one-off"
|
||||
|
|
|
|||
Loading…
Reference in a new issue