Unable to run configure scripts with /bin/sh when building

When trying to build a patched version of Wine to run Cemu, I the build fails early with this error:

unpacking source archive /nix/store/isi23386mc1rvpygkda2kx2dii2q97v2-wine-6.7.tar.xz
source root is wine-6.7
setting SOURCE_DATE_EPOCH to timestamp 1619209123 of file wine-6.7/tools/wrc/writeres.c
applying patch /nix/store/5p944miwsap4gingva49h9hvs1wypaxd-cert-path.patch
patching file dlls/crypt32/unixlib.c
Hunk #2 succeeded at 615 (offset 9 lines).
applying patch /nix/store/mkxcczrnn7pkx4b241ssjx8ppsgy47y9-childwindow.patch
patching file dlls/winex11.drv/vulkan.c
Hunk #1 succeeded at 32 with fuzz 2 (offset -1 lines).
Hunk #2 succeeded at 55 (offset -1 lines).
Hunk #3 succeeded at 63 (offset -1 lines).
Hunk #4 succeeded at 141 (offset 3 lines).
Hunk #5 succeeded at 259 (offset 3 lines).
Hunk #6 succeeded at 292 (offset 3 lines).
Hunk #7 succeeded at 308 (offset 3 lines).
Hunk #8 succeeded at 398 (offset 3 lines).
Hunk #9 succeeded at 625 (offset 57 lines).
configure flags: --prefix=/nix/store/rcs5g2r0c9flzjvqjgmymg6q3bb917vr-wine-wow-6.7 --enable-win64
/nix/store/f0xsm2fhy00sd2254kkvgswgp2wn55wh-stdenv-linux/setup: /build/wine-6.7/configure: /bin/sh: bad interpreter: No such file or directory

Similarly, when trying to rebuild Citra to try and make QT work again:

@nix { "action": "setPhase", "phase": "qtPreHook" }
qtPreHook
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/460bfqavcs0khsii0zwbzp67cagxrh4r-citra-3f13e1c
source root is citra-3f13e1c
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
fixing cmake files...
cmake flags: -DCMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY=OFF -DCMAKE_FIND_USE_PACKAGE_REGISTRY=OFF -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_SKIP_BUILD_RPATH=ON -DBUILD_TESTING=OFF -DCMAKE_INSTALL_LOCALEDIR=/nix/store/bvk8rj2948jgqaj0q1g3xvbpdbwvs8vl-citra-2020-12-07/share/locale -DCMAKE_INSTALL_LIBEXECDIR=/nix/store/bvk8rj2948jgqaj0q1g3xvbpdbwvs8vl-citra-2020-12-07/libexec -DCMAKE_INSTALL_LIBDIR=/nix/store/bvk8rj2948jgqaj0q1g3xvbpdbwvs8vl-citra-2020-12-07/lib -DCMAKE_INSTALL_DOCDIR=/nix/store/bvk8rj2948jgqaj0q1g3xvbpdbwvs8vl-citra-2020-12-07/share/doc/citra -DCMAKE_INSTALL_INFODIR=/nix/store/bvk8rj2948jgqaj0q1g3xvbpdbwvs8vl-citra-2020-12-07/share/info -DCMAKE_INSTALL_MANDIR=/nix/store/bvk8rj2948jgqaj0q1g3xvbpdbwvs8vl-citra-2020-12-07/share/man -DCMAKE_INSTALL_OLDINCLUDEDIR=/nix/store/bvk8rj2948jgqaj0q1g3xvbpdbwvs8vl-citra-2020-12-07/include -DCMAKE_INSTALL_INCLUDEDIR=/nix/store/bvk8rj2948jgqaj0q1g3xvbpdbwvs8vl-citra-2020-12-07/include -DCMAKE_INSTALL_SBINDIR=/nix/store/bvk8rj2948jgqaj0q1g3xvbpdbwvs8vl-citra-2020-12-07/sbin -DCMAKE_INSTALL_BINDIR=/nix/store/bvk8rj2948jgqaj0q1g3xvbpdbwvs8vl-citra-2020-12-07/bin -DCMAKE_INSTALL_NAME_DIR=/nix/store/bvk8rj2948jgqaj0q1g3xvbpdbwvs8vl-citra-2020-12-07/lib -DCMAKE_POLICY_DEFAULT_CMP0025=NEW -DCMAKE_OSX_SYSROOT= -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_STRIP=/nix/store/77i6h1kjpdww9zzpvkmgyym2mz65yff1-binutils-2.35.1/bin/strip -DCMAKE_RANLIB=/nix/store/77i6h1kjpdww9zzpvkmgyym2mz65yff1-binutils-2.35.1/bin/ranlib -DCMAKE_AR=/nix/store/77i6h1kjpdww9zzpvkmgyym2mz65yff1-binutils-2.35.1/bin/ar -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_INSTALL_PREFIX=/nix/store/bvk8rj2948jgqaj0q1g3xvbpdbwvs8vl-citra-2020-12-07  
-- The C compiler identification is GNU 10.3.0
-- The CXX compiler identification is GNU 10.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /nix/store/35pnk5kwi26m3ph2bc7dxwjnavpzl8cn-gcc-wrapper-10.3.0/bin/gcc
-- Check for working C compiler: /nix/store/35pnk5kwi26m3ph2bc7dxwjnavpzl8cn-gcc-wrapper-10.3.0/bin/gcc - broken
CMake Error at /nix/store/zzqzl5lm59mc04fd8f1wbwl7nmxvv1bb-cmake-3.19.7/share/cmake-3.19/Modules/CMakeTestCCompiler.cmake:66 (message):
  The C compiler

    "/nix/store/35pnk5kwi26m3ph2bc7dxwjnavpzl8cn-gcc-wrapper-10.3.0/bin/gcc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /build/citra-3f13e1c/build/CMakeFiles/CMakeTmp
    
    Run Build Command(s):/nix/store/g2fna66r9m081w1h1zj857j06jigx6cq-gnumake-4.3/bin/make cmTC_21103/fast && /nix/store/g2fna66r9m081w1h1zj857j06jigx6cq-gnumake-4.3/bin/make  -f CMakeFiles/cmTC_21103.dir/build.make CMakeFiles/cmTC_21103.dir/build
    make[1]: Entering directory '/build/citra-3f13e1c/build/CMakeFiles/CMakeTmp'
    make[1]: /bin/sh: No such file or directory
    make[1]: *** [CMakeFiles/cmTC_21103.dir/build.make:84: CMakeFiles/cmTC_21103.dir/testCCompiler.c.o] Error 127
    make[1]: Leaving directory '/build/citra-3f13e1c/build/CMakeFiles/CMakeTmp'
    make: *** [Makefile:140: cmTC_21103/fast] Error 2
    
    

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:12 (project)


-- Configuring incomplete, errors occurred!
See also "/build/citra-3f13e1c/build/CMakeFiles/CMakeOutput.log".
See also "/build/citra-3f13e1c/build/CMakeFiles/CMakeError.log".

A common line in both of them is /bin/sh: No such file or directory. This doesn’t happen when doing the build manually, even when I set the shell to pure, and I have no idea if this is a Nix bug, a Nixpkgs bug, or a NixOS bug. All I can really say is that I did a massive update last night along with a garbage collection, largely to update my AMD graphics drivers and uncap my CPU from power saving mode.

My NixOS version is 21.11pre291991.ea7d4aa9b82 (Porcupine) with Linux 5.10.37 on x86_64. My version before the update where everything still worked (but very slowly) was 21.05pre284548.1fe6ed37fd9 with Linux 5.10.30.

Ok, this seems to be a known problem: stdenv-linux/setup: ./configure: /bin/sh: bad interpreter: No such file or directory · Issue #124372 · NixOS/nixpkgs · GitHub