diff --git a/modules/installer/tools/nixos-rebuild.sh b/modules/installer/tools/nixos-rebuild.sh index 255c8150bdd..fb26279e7c7 100644 --- a/modules/installer/tools/nixos-rebuild.sh +++ b/modules/installer/tools/nixos-rebuild.sh @@ -191,9 +191,6 @@ fi # If we're not just building, then make the new configuration the boot # default and/or activate it now. if [ "$action" = switch -o "$action" = boot -o "$action" = test ]; then - # Just in case the new configuration hangs the system, do a sync now. - sync - $pathToConfig/bin/switch-to-configuration "$action" fi diff --git a/modules/system/activation/switch-to-configuration.pl b/modules/system/activation/switch-to-configuration.pl index a95ebcaba24..4db53c9043e 100644 --- a/modules/system/activation/switch-to-configuration.pl +++ b/modules/system/activation/switch-to-configuration.pl @@ -33,9 +33,13 @@ openlog("nixos", "", LOG_USER); # Install or update the bootloader. if ($action eq "switch" || $action eq "boot") { system("@installBootLoader@ $out") == 0 or exit 1; - exit 0 if $action eq "boot"; } +# Just in case the new configuration hangs the system, do a sync now. +system("sync") unless ($ENV{"NIXOS_NO_SYNC"} // "") eq "1"; + +exit 0 if $action eq "boot"; + # Check if we can activate the new configuration. my $oldVersion = read_file("/run/current-system/init-interface-version", err_mode => 'quiet') // ""; my $newVersion = read_file("$out/init-interface-version");