2013-10-26 18:33:09 +02:00
|
|
|
{ stdenv, ghc, packages, buildEnv, makeWrapper }:
|
2011-12-03 17:19:43 +01:00
|
|
|
|
2013-10-26 18:33:09 +02:00
|
|
|
assert packages != [];
|
2011-12-03 17:19:43 +01:00
|
|
|
|
2013-10-26 18:33:09 +02:00
|
|
|
let
|
|
|
|
ghc761OrLater = stdenv.lib.versionOlder "7.6.1" ghc.version;
|
|
|
|
packageDBFlag = if ghc761OrLater then "--package-db" else "--package-conf";
|
|
|
|
libDir = "$out/lib/ghc-${ghc.version}";
|
|
|
|
packageCfgDir = "${libDir}/package.conf.d";
|
|
|
|
in
|
|
|
|
buildEnv {
|
|
|
|
name = "haskell-env-${ghc.name}";
|
2013-10-28 17:54:28 +01:00
|
|
|
paths = stdenv.lib.filter (x: x ? ghc) (stdenv.lib.closePropagation packages) ++ [ghc];
|
2013-10-26 18:33:09 +02:00
|
|
|
postBuild = ''
|
|
|
|
. ${makeWrapper}/nix-support/setup-hook
|
2011-12-03 17:19:43 +01:00
|
|
|
|
2011-12-04 17:07:39 +01:00
|
|
|
for prg in ghc ghci ghc-${ghc.version} ghci-${ghc.version}; do
|
2013-10-26 18:33:09 +02:00
|
|
|
rm -f $out/bin/$prg
|
|
|
|
makeWrapper ${ghc}/bin/$prg $out/bin/$prg \
|
|
|
|
--add-flags '"-B$NIX_GHC_LIBDIR"' \
|
|
|
|
--set "NIX_GHC" "$out/bin/ghc" \
|
|
|
|
--set "NIX_GHCPKG" "$out/bin/ghc-pkg" \
|
|
|
|
--set "NIX_GHC_LIBDIR" "${libDir}"
|
2011-12-04 17:07:39 +01:00
|
|
|
done
|
2011-12-03 17:19:43 +01:00
|
|
|
|
2011-12-04 17:07:39 +01:00
|
|
|
for prg in runghc runhaskell; do
|
2013-10-26 18:33:09 +02:00
|
|
|
rm -f $out/bin/$prg
|
|
|
|
makeWrapper ${ghc}/bin/$prg $out/bin/$prg \
|
|
|
|
--add-flags "-f $out/bin/ghc" \
|
|
|
|
--set "NIX_GHC" "$out/bin/ghc" \
|
|
|
|
--set "NIX_GHCPKG" "$out/bin/ghc-pkg" \
|
|
|
|
--set "NIX_GHC_LIBDIR" "${libDir}"
|
2011-12-03 17:19:43 +01:00
|
|
|
done
|
|
|
|
|
2011-12-04 17:07:39 +01:00
|
|
|
for prg in ghc-pkg ghc-pkg-${ghc.version}; do
|
2013-10-26 18:33:09 +02:00
|
|
|
rm -f $out/bin/$prg
|
|
|
|
makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "${packageDBFlag} ${packageCfgDir}"
|
2011-12-04 17:07:39 +01:00
|
|
|
done
|
2011-12-03 17:19:43 +01:00
|
|
|
|
2013-10-26 18:33:09 +02:00
|
|
|
$out/bin/ghc-pkg recache
|
2011-12-03 17:19:43 +01:00
|
|
|
'';
|
|
|
|
}
|