diff --git a/modules/installer/tools/nixos-install.sh b/modules/installer/tools/nixos-install.sh index 4d3d3db08617..d1fdc5820b15 100644 --- a/modules/installer/tools/nixos-install.sh +++ b/modules/installer/tools/nixos-install.sh @@ -29,12 +29,12 @@ if ! grep -F -q " $mountPoint " /proc/mounts; then echo "$mountPoint doesn't appear to be a mount point" exit 1 fi - + if ! test -e "$mountPoint/$NIXOS_CONFIG"; then echo "configuration file $NIXOS_CONFIG doesn't exist" exit 1 fi - + # Do a nix-pull to speed up building. if test -n "@nixosURL@" -a ${NIXOS_PULL:-1} != 0; then diff --git a/modules/installer/tools/nixos-rebuild.sh b/modules/installer/tools/nixos-rebuild.sh index e21a34f996c1..f7c22b98dd76 100644 --- a/modules/installer/tools/nixos-rebuild.sh +++ b/modules/installer/tools/nixos-rebuild.sh @@ -47,7 +47,7 @@ EOF # Parse the command line. -extraBuildFlags= +extraBuildFlags=() action= pullManifest= buildNix=1 @@ -79,20 +79,20 @@ while test "$#" -gt 0; do upgrade=1 ;; --show-trace|--no-build-hook|--keep-failed|-K|--keep-going|-k|--verbose|-v|--fallback) - extraBuildFlags="$extraBuildFlags $i" + extraBuildFlags+=("$i") ;; --max-jobs|-j|--cores|-I) j="$1"; shift 1 - extraBuildFlags="$extraBuildFlags $i $j" + extraBuildFlags+=("$i" "$j") ;; --option) j="$1"; shift 1 k="$1"; shift 1 - extraBuildFlags="$extraBuildFlags $i $j $k" + extraBuildFlags+=("$i" "$j" "$k") ;; --fast) buildNix= - extraBuildFlags="$extraBuildFlags --show-trace" + extraBuildFlags+=(--show-trace) ;; *) echo "$0: unknown option \`$i'" @@ -104,7 +104,7 @@ done if test -z "$action"; then showSyntax; fi if test "$action" = dry-run; then - extraBuildFlags="$extraBuildFlags --dry-run" + extraBuildFlags+=(--dry-run) fi if test -n "$rollback"; then @@ -156,9 +156,9 @@ fi # more conservative. if [ -n "$buildNix" ]; then echo "building Nix..." >&2 - if ! nix-build '' -A config.environment.nix -o $tmpDir/nix $extraBuildFlags > /dev/null; then - if ! nix-build '' -A nixFallback -o $tmpDir/nix $extraBuildFlags > /dev/null; then - nix-build '' -A nixUnstable -o $tmpDir/nix $extraBuildFlags > /dev/null + if ! nix-build '' -A config.environment.nix -o $tmpDir/nix "${extraBuildFlags[@]}" > /dev/null; then + if ! nix-build '' -A nixFallback -o $tmpDir/nix "${extraBuildFlags[@]}" > /dev/null; then + nix-build '' -A nixUnstable -o $tmpDir/nix "${extraBuildFlags[@]}" > /dev/null fi fi PATH=$tmpDir/nix/bin:$PATH @@ -171,16 +171,16 @@ fi if test -z "$rollback"; then echo "building the system configuration..." >&2 if test "$action" = switch -o "$action" = boot; then - nix-env $extraBuildFlags -p /nix/var/nix/profiles/system -f '' --set -A system + nix-env "${extraBuildFlags[@]}" -p /nix/var/nix/profiles/system -f '' --set -A system pathToConfig=/nix/var/nix/profiles/system elif test "$action" = test -o "$action" = build -o "$action" = dry-run; then - nix-build '' -A system -K -k $extraBuildFlags > /dev/null + nix-build '' -A system -K -k "${extraBuildFlags[@]}" > /dev/null pathToConfig=./result elif [ "$action" = build-vm ]; then - nix-build '' -A vm -K -k $extraBuildFlags > /dev/null + nix-build '' -A vm -K -k "${extraBuildFlags[@]}" > /dev/null pathToConfig=./result elif [ "$action" = build-vm-with-bootloader ]; then - nix-build '' -A vmWithBootLoader -K -k $extraBuildFlags > /dev/null + nix-build '' -A vmWithBootLoader -K -k "${extraBuildFlags[@]}" > /dev/null pathToConfig=./result else showSyntax