Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion pkgs/development/haskell-modules/generic-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,14 @@ let

intermediatesDir = "share/haskell/${ghc.version}/${pname}-${version}/dist";

# On old ghcjs, the jsexe directories are the output but on the js backend they seem to be treated as intermediates
Comment thread
alexfmpe marked this conversation as resolved.
Outdated
jsexe = rec {
shouldUseNode = isGhcjs;
shouldAdd = stdenv.hostPlatform.isGhcjs && isExecutable;
shouldCopy = shouldAdd && !doInstallIntermediates;
shouldSymlink = shouldAdd && doInstallIntermediates;
};

# This is a script suitable for --test-wrapper of Setup.hs' test command
# (https://cabal.readthedocs.io/en/3.12/setup-commands.html#cmdoption-runhaskell-Setup.hs-test-test-wrapper).
# We use it to set some environment variables that the test suite may need,
Expand Down Expand Up @@ -820,7 +828,8 @@ lib.fix (
find $packageConfDir -maxdepth 0 -empty -delete;
''
}
${optionalString isGhcjs ''

${optionalString jsexe.shouldUseNode ''
for exeDir in "${binDir}/"*.jsexe; do
exe="''${exeDir%.jsexe}"
printWords '#!${nodejs}/bin/node' > "$exe"
Expand All @@ -831,6 +840,14 @@ lib.fix (
''}
${optionalString doCoverage "mkdir -p $out/share && cp -r dist/hpc $out/share"}

${optionalString jsexe.shouldCopy ''
for jsexeDir in dist/build/*/*.jsexe; do
bn=$(basename $jsexeDir)
exe="''${bn%.jsexe}"
cp -r dist/build/$exe/$exe.jsexe ${binDir}
done
''}

${optionalString enableSeparateDocOutput ''
for x in ${docdir "$doc"}"/html/src/"*.html; do
remove-references-to -t $out $x
Expand All @@ -849,6 +866,14 @@ lib.fix (
mkdir -p "$installIntermediatesDir"
cp -r dist/build "$installIntermediatesDir"
runHook postInstallIntermediates

${optionalString jsexe.shouldSymlink ''
for jsexeDir in $installIntermediatesDir/build/*/*.jsexe; do
bn=$(basename $jsexeDir)
exe="''${bn%.jsexe}"
(cd ${binDir} && ln -s $installIntermediatesDir/build/$exe/$exe.jsexe)
done
''}
'';

passthru = passthru // rec {
Expand Down