diff --git a/scripts/nix-build.in b/scripts/nix-build.in
index 4ceec4df652ae9e4c3d6507d848f66237e63408b..fb70331bfa13fe424c8e35706f04d8d94adc3ca5 100755
--- a/scripts/nix-build.in
+++ b/scripts/nix-build.in
@@ -186,7 +186,7 @@ foreach my $expr (@exprs) {
             'set +e; ' .
             'PS1="\n\[\033[1;32m\][nix-build:\w]$\[\033[0m\] "; ' .
             $envCommand);
-        exec($ENV{SHELL}, "--rcfile", $rcfile);
+        exec($ENV{NIX_BUILD_SHELL} // "bash", "--rcfile", $rcfile);
         die;
     }