diff --git a/modules/installer/tools/nixos-rebuild.sh b/modules/installer/tools/nixos-rebuild.sh index 28a1d2282939..b9272f31ac6f 100644 --- a/modules/installer/tools/nixos-rebuild.sh +++ b/modules/installer/tools/nixos-rebuild.sh @@ -96,10 +96,6 @@ done if [ -z "$action" ]; then showSyntax; fi -if [ "$action" = dry-run ]; then - extraBuildFlags+=(--dry-run) -fi - if [ -n "$rollback" ]; then buildNix= fi @@ -129,7 +125,7 @@ fi # First build Nix, since NixOS may require a newer version than the # current one. Of course, the same goes for Nixpkgs, but Nixpkgs is # more conservative. -if [ -n "$buildNix" ]; then +if [ "$action" != dry-run -a -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 @@ -150,6 +146,11 @@ if nixos=$(nix-instantiate --find-file nixos "${extraBuildFlags[@]}"); then fi +if [ "$action" = dry-run ]; then + extraBuildFlags+=(--dry-run) +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").