3
0
Fork 0
forked from mirrors/nixpkgs

nixos-rebuild: Handle options with spaces in them

Like ‘--option binary-caches "http://foo http://bar"’
This commit is contained in:
Eelco Dolstra 2012-11-22 12:04:00 +01:00
parent a4bcb26b1a
commit 994a15bc25
2 changed files with 15 additions and 15 deletions

View file

@ -29,12 +29,12 @@ if ! grep -F -q " $mountPoint " /proc/mounts; then
echo "$mountPoint doesn't appear to be a mount point" echo "$mountPoint doesn't appear to be a mount point"
exit 1 exit 1
fi fi
if ! test -e "$mountPoint/$NIXOS_CONFIG"; then if ! test -e "$mountPoint/$NIXOS_CONFIG"; then
echo "configuration file $NIXOS_CONFIG doesn't exist" echo "configuration file $NIXOS_CONFIG doesn't exist"
exit 1 exit 1
fi fi
# Do a nix-pull to speed up building. # Do a nix-pull to speed up building.
if test -n "@nixosURL@" -a ${NIXOS_PULL:-1} != 0; then if test -n "@nixosURL@" -a ${NIXOS_PULL:-1} != 0; then

View file

@ -47,7 +47,7 @@ EOF
# Parse the command line. # Parse the command line.
extraBuildFlags= extraBuildFlags=()
action= action=
pullManifest= pullManifest=
buildNix=1 buildNix=1
@ -79,20 +79,20 @@ while test "$#" -gt 0; do
upgrade=1 upgrade=1
;; ;;
--show-trace|--no-build-hook|--keep-failed|-K|--keep-going|-k|--verbose|-v|--fallback) --show-trace|--no-build-hook|--keep-failed|-K|--keep-going|-k|--verbose|-v|--fallback)
extraBuildFlags="$extraBuildFlags $i" extraBuildFlags+=("$i")
;; ;;
--max-jobs|-j|--cores|-I) --max-jobs|-j|--cores|-I)
j="$1"; shift 1 j="$1"; shift 1
extraBuildFlags="$extraBuildFlags $i $j" extraBuildFlags+=("$i" "$j")
;; ;;
--option) --option)
j="$1"; shift 1 j="$1"; shift 1
k="$1"; shift 1 k="$1"; shift 1
extraBuildFlags="$extraBuildFlags $i $j $k" extraBuildFlags+=("$i" "$j" "$k")
;; ;;
--fast) --fast)
buildNix= buildNix=
extraBuildFlags="$extraBuildFlags --show-trace" extraBuildFlags+=(--show-trace)
;; ;;
*) *)
echo "$0: unknown option \`$i'" echo "$0: unknown option \`$i'"
@ -104,7 +104,7 @@ done
if test -z "$action"; then showSyntax; fi if test -z "$action"; then showSyntax; fi
if test "$action" = dry-run; then if test "$action" = dry-run; then
extraBuildFlags="$extraBuildFlags --dry-run" extraBuildFlags+=(--dry-run)
fi fi
if test -n "$rollback"; then if test -n "$rollback"; then
@ -156,9 +156,9 @@ fi
# more conservative. # more conservative.
if [ -n "$buildNix" ]; then if [ -n "$buildNix" ]; then
echo "building Nix..." >&2 echo "building Nix..." >&2
if ! nix-build '<nixos>' -A config.environment.nix -o $tmpDir/nix $extraBuildFlags > /dev/null; then if ! nix-build '<nixos>' -A config.environment.nix -o $tmpDir/nix "${extraBuildFlags[@]}" > /dev/null; then
if ! nix-build '<nixos>' -A nixFallback -o $tmpDir/nix $extraBuildFlags > /dev/null; then if ! nix-build '<nixos>' -A nixFallback -o $tmpDir/nix "${extraBuildFlags[@]}" > /dev/null; then
nix-build '<nixpkgs>' -A nixUnstable -o $tmpDir/nix $extraBuildFlags > /dev/null nix-build '<nixpkgs>' -A nixUnstable -o $tmpDir/nix "${extraBuildFlags[@]}" > /dev/null
fi fi
fi fi
PATH=$tmpDir/nix/bin:$PATH PATH=$tmpDir/nix/bin:$PATH
@ -171,16 +171,16 @@ fi
if test -z "$rollback"; then if test -z "$rollback"; then
echo "building the system configuration..." >&2 echo "building the system configuration..." >&2
if test "$action" = switch -o "$action" = boot; then if test "$action" = switch -o "$action" = boot; then
nix-env $extraBuildFlags -p /nix/var/nix/profiles/system -f '<nixos>' --set -A system nix-env "${extraBuildFlags[@]}" -p /nix/var/nix/profiles/system -f '<nixos>' --set -A system
pathToConfig=/nix/var/nix/profiles/system pathToConfig=/nix/var/nix/profiles/system
elif test "$action" = test -o "$action" = build -o "$action" = dry-run; then elif test "$action" = test -o "$action" = build -o "$action" = dry-run; then
nix-build '<nixos>' -A system -K -k $extraBuildFlags > /dev/null nix-build '<nixos>' -A system -K -k "${extraBuildFlags[@]}" > /dev/null
pathToConfig=./result pathToConfig=./result
elif [ "$action" = build-vm ]; then elif [ "$action" = build-vm ]; then
nix-build '<nixos>' -A vm -K -k $extraBuildFlags > /dev/null nix-build '<nixos>' -A vm -K -k "${extraBuildFlags[@]}" > /dev/null
pathToConfig=./result pathToConfig=./result
elif [ "$action" = build-vm-with-bootloader ]; then elif [ "$action" = build-vm-with-bootloader ]; then
nix-build '<nixos>' -A vmWithBootLoader -K -k $extraBuildFlags > /dev/null nix-build '<nixos>' -A vmWithBootLoader -K -k "${extraBuildFlags[@]}" > /dev/null
pathToConfig=./result pathToConfig=./result
else else
showSyntax showSyntax