nix-bootstrap.sh: fix shellcheck warnings

It also changes how the arguments are being passed around.
This commit is contained in:
zimbatm 2020-10-22 15:15:21 +02:00
parent 565770f037
commit 5672912336
No known key found for this signature in database
GPG Key ID: 71BAF6D40C1D63D7

View File

@ -1,35 +1,35 @@
#!/bin/sh
cmd=sh
if ! [ $# -eq 0 ]; then
cmd=$@
if [ $# -gt 0 ]; then
set -- sh
fi
# should download this in the future
# but the mirror is down
proot=`dirname $0`/proot-`uname -p`
proot=$(dirname "$0")/proot-$(uname -p)
export PROOT_NO_SECCOMP=1
nixdir=$HOME/.nix
OLD_NIX_PATH=$NIX_PATH
if [ -e $HOME/.nix-profile/etc/profile.d/nix.sh ]; then . $HOME/.nix-profile/etc/profile.d/nix.sh; fi
if ! [ -z "$OLD_NIX_PATH" ]; then NIX_PATH="$OLD_NIX_PATH"; fi
# shellcheck disable=SC1090
if [ -e "$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then . "$HOME/.nix-profile/etc/profile.d/nix.sh"; fi
if [ -n "$OLD_NIX_PATH" ]; then NIX_PATH="$OLD_NIX_PATH"; fi
if [ -z "$IN_PROOT" ]; then
export IN_PROOT=1
if ! [ -d $nixdir ]; then
mkdir -p $nixdir
if ! [ -d "$nixdir" ]; then
mkdir -p "$nixdir"
s=$(mktemp)
curl https://nixos.org/nix/install -o $s
$proot -b $nixdir:/nix $0 sh $s
curl https://nixos.org/nix/install -o "$s"
$proot -b "$nixdir:/nix" "$0" sh "$s"
fi
$proot -b $nixdir:/nix $0 $cmd
$proot -b "$nixdir:/nix" "$0" "$@"
export IN_PROOT=
exit
elif ! [ $# -eq 0 ]; then
exec $cmd
elif [ $# -gt 0 ]; then
exec "$@"
fi