kopia lustrzana https://github.com/jupyterhub/repo2docker
fix up nix-shell-wrapper for .binder feature
rodzic
05273abb38
commit
34ad355de6
|
@ -8,38 +8,38 @@ _term() {
|
|||
|
||||
trap _term SIGTERM
|
||||
|
||||
# if there is a binder/ sub-directory it takes precedence
|
||||
# files outside it are ignored
|
||||
# find binder sub-directory (if present)
|
||||
for dir in "./.binder" "./binder"; do
|
||||
binder_dir="./"
|
||||
for dir in "./binder" "./.binder" ; do
|
||||
if [ -e $dir ]; then
|
||||
binder_dir=$dir
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# if there is a binder/ sub-directory it takes precedence
|
||||
# files outside it are ignored
|
||||
if [ -z $binder_dir ]; then
|
||||
nixpath="$binder_dir/default.nix";
|
||||
if [ -f $binder_dir/start ]; then
|
||||
chmod u+x $binder_dir/start
|
||||
# Using `$@`` here which is what the internet recommends leads to
|
||||
# errors when the command is something like `jupyter --ip=0.0.0.0 ...`
|
||||
# as nix-shell picks that up as an argument to it instead of the command.
|
||||
# There are several issues on the nix repos discussing this and adding support
|
||||
# for -- to indicate "all arguments after this are for the command, not nix-shell"
|
||||
# but it seems they have stalled/not yet produced an implementation.
|
||||
# So let's use `$*` for now.
|
||||
nix-shell $nixpath --command "$binder_dir/start $*" &
|
||||
else
|
||||
nix-shell $nixpath --command "$*" &
|
||||
fi
|
||||
# raise error if both binder and .binder are found
|
||||
if [[ -d "./binder" && -d "./.binder" ]]; then
|
||||
echo "Error: Found both binder and .binder directories."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "binder_dir is: $binder_dir"
|
||||
|
||||
nixpath="$binder_dir/default.nix";
|
||||
if [ -f $binder_dir/start ]; then
|
||||
chmod u+x $binder_dir/start
|
||||
# Using `$@`` here which is what the internet recommends leads to
|
||||
# errors when the command is something like `jupyter --ip=0.0.0.0 ...`
|
||||
# as nix-shell picks that up as an argument to it instead of the command.
|
||||
# There are several issues on the nix repos discussing this and adding support
|
||||
# for -- to indicate "all arguments after this are for the command, not nix-shell"
|
||||
# but it seems they have stalled/not yet produced an implementation.
|
||||
# So let's use `$*` for now.
|
||||
nix-shell $nixpath --command "$binder_dir/start $*" &
|
||||
else
|
||||
nixpath="./default.nix";
|
||||
if [ -f ./start ]; then
|
||||
chmod u+x ./start
|
||||
nix-shell $nixpath --command "./start $*" &
|
||||
else
|
||||
nix-shell $nixpath --command "$*" &
|
||||
fi
|
||||
nix-shell $nixpath --command "$*" &
|
||||
fi
|
||||
|
||||
PID=$!
|
||||
|
|
Ładowanie…
Reference in New Issue