From 9255e349836c26d26f7d7b2e7afb0b5929374ce7 Mon Sep 17 00:00:00 2001 From: Will Cohen Date: Sat, 27 Dec 2025 08:11:17 -0500 Subject: [PATCH] emscripten: fix patchShebangs and add regression test --- pkgs/development/compilers/emscripten/default.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkgs/development/compilers/emscripten/default.nix b/pkgs/development/compilers/emscripten/default.nix index c1663709507a..b6f3e61cbb18 100644 --- a/pkgs/development/compilers/emscripten/default.nix +++ b/pkgs/development/compilers/emscripten/default.nix @@ -73,6 +73,9 @@ stdenv.mkDerivation rec { buildPhase = '' runHook preBuild + # Make Python scripts executable so patchShebangs will patch their shebangs + chmod +x *.py tools/*.py + patchShebangs . # emscripten 4.0.12 requires LLVM tip-of-tree instead of LLVM 21 @@ -146,7 +149,6 @@ stdenv.mkDerivation rec { # Wrap all tools consistently via their .py entry points for b in em++ emcc em-config emar embuilder emcmake emconfigure emmake emranlib emrun emscons emsize; do - chmod +x $appdir/$b.py makeWrapper $appdir/$b.py $out/bin/$b \ --set NODE_PATH ${nodeModules} \ --set EM_EXCLUSIVE_CACHE_ACCESS 1 \ @@ -181,6 +183,12 @@ stdenv.mkDerivation rec { pushd $appdir ${pythonWithPsutil}/bin/python test/runner.py test_hello_world popd + + # fail if any .py files still have unpatched shebangs + if grep -l '#!/usr/bin/env' $appdir/*.py $appdir/tools/*.py 2>/dev/null; then + echo "ERROR: unpatched shebangs found in .py files" + exit 1 +fi runHook postInstall '';