Skip to content

Commit 9966563

Browse files
committed
Fix env-test for cross-compilation variants (static, JS)
Cross-compilation GHC packages only have target-prefixed binaries (e.g. x86_64-unknown-linux-musl-ghc, javascript-unknown-ghcjs-ghc) with no unprefixed bin/ghc symlink. Extract the correct GHC command from NIX_CABAL_FLAGS --with-ghc=... which is set by the env script for all cross-compilation shells.
1 parent a6c51dd commit 9966563

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

flake.nix

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,20 @@
414414
# Source the environment script to set up PATH and env vars
415415
source ${envScript}
416416
417+
# For cross-compilation shells (static/musl, JS), the GHC binary
418+
# has a target prefix (e.g. x86_64-unknown-linux-musl-ghc).
419+
# Extract the correct name from NIX_CABAL_FLAGS if set.
420+
GHC_CMD="ghc"
421+
if [[ -n "''${NIX_CABAL_FLAGS:-}" ]]; then
422+
for flag in $NIX_CABAL_FLAGS; do
423+
case "$flag" in
424+
--with-ghc=*) GHC_CMD="''${flag#--with-ghc=}" ;;
425+
esac
426+
done
427+
fi
428+
417429
echo "=== Testing ${name} ==="
418-
echo -n "GHC: "; ghc --version
430+
echo -n "GHC: "; $GHC_CMD --version
419431
echo -n "Cabal: "; cabal --version | head -1
420432
echo -n "pkg-config packages: "; pkg-config --list-all | wc -l
421433
${lib.optionalString hasHLS ''

0 commit comments

Comments
 (0)