e805baacb7
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>
53 lines
1.0 KiB
Nix
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
|
|
''
|