diff --git a/pkgs/build-support/vm/default.nix b/pkgs/build-support/vm/default.nix index 5b407f530dc8..81a9f89dd100 100644 --- a/pkgs/build-support/vm/default.nix +++ b/pkgs/build-support/vm/default.nix @@ -261,9 +261,12 @@ rec { exit 1 fi - eval "$postVM" + exitCode="$(cat xchg/in-vm-exit)" + if [ "$exitCode" != "0" ]; then + exit "$exitCode" + fi - exit $(cat xchg/in-vm-exit) + eval "$postVM" '';