nix-bundle.sh: fix shellcheck warnings

This commit is contained in:
zimbatm 2020-10-22 14:48:44 +02:00
parent 83742ac8ea
commit 565770f037
No known key found for this signature in database
GPG Key ID: 71BAF6D40C1D63D7

View File

@ -19,7 +19,7 @@ EOF
exit 1
fi
nix_file=`dirname $0`/default.nix
nix_file=$(dirname "$0")/default.nix
target="$1"
shift
@ -38,21 +38,23 @@ shift
bootstrap=nix-bootstrap
if [ "$target" = "nix-bundle" ] || [ "$target" = "nixStable" ] || [ "$target" = "nixUnstable" ] || [ "$target" = "nix" ]; then
bootstrap=nix-bootstrap-nix
elif ! [ -z "$extraTargets" ]; then
elif [ -n "$extraTargets" ]; then
bootstrap=nix-bootstrap-path
fi
expr="with import <nixpkgs> {}; with import $nix_file {}; $bootstrap { target = $target; extraTargets = [ $extraTargets ]; run = \"$exec\"; }"
out=$(nix-store --no-gc-warning -r $(nix-instantiate --no-gc-warning -E "$expr"))
drv=$(nix-instantiate --no-gc-warning -E "$expr")
out=$(nix-store --no-gc-warning --realize "$drv")
if [ -z "$out" ]; then
>&2 echo "$0 failed. Exiting."
exit 1
elif [ -t 1 ]; then
filename=$(basename $exec)
filename=$(basename "$exec")
echo "Nix bundle created at $filename."
cp -f $out $filename
cp -f "$out" "$filename"
else
cat $out
cat "$out"
fi