#! @shell@ -e showSyntax() { # !!! more or less cut&paste from # system/switch-to-configuration.sh (which we call, of course). cat <&1 | grep -q 'running'; then export NIX_REMOTE=${NIX_REMOTE:-daemon} fi # Pull the manifests defined in the configuration (the "manifests" # attribute). Wonderfully hacky. if test -n "$pullManifest"; then manifests=$(nix-instantiate --eval-only --xml --strict '' -A manifests \ | grep '&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 fi fi PATH=$tmpDir/nix/bin:$PATH fi # Either upgrade the configuration in the system profile (for "switch" # or "boot"), or just build it and create a symlink "result" in the # current directory (for "build" and "test"). if test -z "$rollback"; then echo "building the system configuration..." >&2 if test "$action" = switch -o "$action" = boot; then nix-env -p /nix/var/nix/profiles/system -f '' --set -A system $extraBuildFlags 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 pathToConfig=./result elif [ "$action" = build-vm ]; then 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 pathToConfig=./result else showSyntax fi else # test -n "$rollback" if test "$action" = switch -o "$action" = boot; then nix-env --rollback -p /nix/var/nix/profiles/system pathToConfig=/nix/var/nix/profiles/system elif test "$action" = test -o "$action" = build; then systemNumber=$( nix-env -p /nix/var/nix/profiles/system --list-generations | sed -n '/current/ {g; p;}; s/ *\([0-9]*\).*/\1/; h' ) ln -sT /nix/var/nix/profiles/system-${systemNumber}-link ./result pathToConfig=./result else showSyntax fi fi # If we're not just building, then make the new configuration the boot # default and/or activate it now. if test "$action" = switch -o "$action" = boot -o "$action" = test; then $pathToConfig/bin/switch-to-configuration "$action" fi if test "$action" = build-vm; then cat >&2 <