@@ -19,7 +19,7 @@ EOF
1919 exit 1
2020fi
2121
22−nix_file=`dirname $0`/default.nix
22+nix_file=$(dirname "$0")/default.nix
2323
2424target="$1"
2525shift
@@ -38,21 +38,23 @@ shift
3838bootstrap=nix-bootstrap
3939if [ "$target" = "nix-bundle" ] || [ "$target" = "nixStable" ] || [ "$target" = "nixUnstable" ] || [ "$target" = "nix" ]; then
4040 bootstrap=nix-bootstrap-nix
41−elif ! [ -z "$extraTargets" ]; then
41+elif [ -n "$extraTargets" ]; then
4242 bootstrap=nix-bootstrap-path
4343fi
4444
4545expr="with import <nixpkgs> {}; with import $nix_file {}; $bootstrap { target = $target; extraTargets = [ $extraTargets ]; run = \"$exec\"; }"
4646
47−out=$(nix-store --no-gc-warning -r $(nix-instantiate --no-gc-warning -E "$expr"))
47+drv=$(nix-instantiate --no-gc-warning -E "$expr")
48+
49+out=$(nix-store --no-gc-warning --realize "$drv")
4850
4951if [ -z "$out" ]; then
5052 >&2 echo "$0 failed. Exiting."
5153 exit 1
5254elif [ -t 1 ]; then
53− filename=$(basename $exec)
55+ filename=$(basename "$exec")
5456 echo "Nix bundle created at $filename."
55− cp -f $out $filename
57+ cp -f "$out" "$filename"
5658else
57− cat $out
59+ cat "$out"
5860fi