@@ -1,4 +1,4 @@
1−{ stdenv, buildPackages, ghc, lib, gobject-introspection ? null, haskellLib, makeConfigFiles, ghcForComponent, hsPkgs, runCommand, libffi, gmp }:
1+{ stdenv, buildPackages, ghc, lib, gobject-introspection ? null, haskellLib, makeConfigFiles, ghcForComponent, hsPkgs, runCommand, libffi, gmp, nodejs }:
22
33{ componentId
44, component
@@ -142,7 +142,8 @@ let
142142 && (haskellLib.isLibrary componentId)
143143 && !haskellLib.isCrossHost;
144144
145− exeExt = lib.optionalString stdenv.hostPlatform.isWindows ".exe";
145+ exeExt = if stdenv.hostPlatform.isGhcjs then ".jsexe/all.js" else
146+ if stdenv.hostPlatform.isWindows then ".exe" else "";
146147 exeName = componentId.cname + exeExt;
147148 testExecutable = "dist/build/${componentId.cname}/${exeName}";
148149
@@ -313,7 +314,13 @@ stdenv.mkDerivation ({
313314 ${(lib.optionalString (haskellLib.isTest componentId || haskellLib.isBenchmark componentId || haskellLib.isAll componentId) ''
314315 mkdir -p $out/bin
315316 if [ -f ${testExecutable} ]; then
316− cp ${testExecutable} $out/bin/
317+ mkdir -p $(dirname $out/bin/${exeName})
318+ ${if stdenv.hostPlatform.isGhcjs then ''
319+ cat <(echo \#!${lib.getBin buildPackages.nodejs}/bin/node) ${testExecutable} >| $out/bin/${exeName}
320+ chmod +x $out/bin/${exeName}
321+ '' else ''
322+ cp -r ${testExecutable} $(dirname $out/bin/${exeName})
323+ ''}
317324 fi
318325 '')
319326 # In case `setup copy` did not creat this