repo2docker/repo2docker/buildpacks/nix/nix-shell-wrapper

33 wiersze
641 B
Bash

#!/bin/bash
_term() {
echo "Caught SIGTERM signal!"
# kill -TERM "$PID" 2>/dev/null
exit 0
}
trap _term SIGTERM
# if there is a binder/ sub-directory it takes precedence
# files outside it are ignored
if [ -e ./binder ]; then
nixpath="./binder/default.nix";
if [ -f ./binder/start ]; then
chmod u+x ./binder/start
nix-shell $nixpath --command "./binder/start $*" &
else
nix-shell $nixpath --command "$*" &
fi
else
nixpath="./default.nix";
if [ -f ./start ]; then
chmod u+x ./start
nix-shell $nixpath --command "./start $*" &
else
nix-shell $nixpath --command "$*" &
fi
fi
PID=$!
wait "$PID"