Files
Alex Tunstall e805baacb7 haskell.{compiler,packages}.microhs: init
The package set is built entirely from source using the stdenv and Hugs.

This also replaces the recently added microhs package, which was built
from pre-generated compiler output.

Co-authored-by: sternenseemann <sternenseemann@systemli.org>
2026-04-09 22:33:33 +01:00

53 lines
1.0 KiB
Nix

{
lib,
runCommand,
runtimeShell,
writeShellScript,
}:
{
microhs,
packages,
}:
let
packages' = [ microhs ] ++ lib.filter (p: p != null) packages;
extraFlags = lib.concatMapStringsSep " " (
p: "-a${p}/lib/mcabal/${microhs.haskellCompilerName}"
) packages';
wrapper = writeShellScript "mhs-wrapper" ''
args=("$@")
noExtra=0
for ((i=0; i<"''${#args[@]}"; ++i)); do
case "''${args[i]}" in
--version | --numeric-version)
noExtra=1
;;
*)
;;
esac
done
if test "$noExtra" -eq 0; then
for arg in ${extraFlags}; do
args[i++]="$arg"
done
fi
if (( "''${NIX_DEBUG:-0}" >= 1 )); then
printf 'mhs-wrapper: mhs %s\n' "''${args[*]}" >&2
fi
exec ${microhs}/bin/mhs "''${args[@]}"
'';
in
runCommand "${microhs.name}-wrapped"
{
inherit (microhs) passthru;
}
''
mkdir -p $out/bin
cp -rs ${microhs}/bin/* $out/bin/
rm $out/bin/mhs 2>/dev/null || true
cp ${wrapper} $out/bin/mhs
''