2011-12-04 16:07:39 +00:00
|
|
|
{stdenv, ghc, packages ? [], makeWrapper}:
|
2011-12-03 16:19:43 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2012-03-21 11:46:15 +00:00
|
|
|
name = "haskell-env-${ghc.name}";
|
2011-12-03 16:19:43 +00:00
|
|
|
|
|
|
|
allPackages = stdenv.lib.closePropagation packages;
|
|
|
|
buildInputs = allPackages ++ [makeWrapper];
|
|
|
|
propagatedBuildInputs = packages;
|
|
|
|
|
|
|
|
unpackPhase = "true";
|
|
|
|
|
|
|
|
installPhase = ''
|
2011-12-04 16:07:39 +00:00
|
|
|
originalTopDir="${ghc}/lib/ghc-${ghc.version}"
|
2011-12-03 16:19:43 +00:00
|
|
|
originalPkgDir="$originalTopDir/package.conf.d"
|
|
|
|
linkedTopDir="$out/lib"
|
|
|
|
linkedPkgDir="$linkedTopDir/package.conf.d"
|
|
|
|
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p $out/bin
|
|
|
|
mkdir -p $linkedTopDir
|
|
|
|
mkdir -p $linkedPkgDir
|
2011-12-03 16:19:43 +00:00
|
|
|
|
2011-12-04 16:07:39 +00:00
|
|
|
echo "Linking GHC core libraries:"
|
2011-12-03 16:19:43 +00:00
|
|
|
|
2011-12-11 17:19:36 +00:00
|
|
|
echo -n "Linking $originalTopDir "
|
2012-03-21 11:46:12 +00:00
|
|
|
for f in "$originalTopDir/"*; do
|
2011-12-11 17:19:36 +00:00
|
|
|
if test -f $f; then
|
|
|
|
ln -s $f $linkedTopDir
|
|
|
|
echo -n .
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
echo
|
2011-12-03 16:19:43 +00:00
|
|
|
|
2011-12-04 16:07:39 +00:00
|
|
|
echo -n "Linking $originalPkgDir "
|
2012-03-21 11:46:12 +00:00
|
|
|
for f in "$originalPkgDir/"*.conf; do
|
2011-12-04 16:07:39 +00:00
|
|
|
ln -s $f $linkedPkgDir
|
|
|
|
echo -n .
|
2011-12-03 16:19:43 +00:00
|
|
|
done
|
2011-12-04 16:07:39 +00:00
|
|
|
echo
|
2011-12-03 16:19:43 +00:00
|
|
|
|
2011-12-04 16:07:39 +00:00
|
|
|
echo "Linking selected packages and dependencies:"
|
2011-12-03 16:19:43 +00:00
|
|
|
|
2011-12-04 16:07:39 +00:00
|
|
|
for currentPath in ${stdenv.lib.concatStringsSep " " allPackages}; do
|
|
|
|
currentPkgDir="$currentPath/lib/ghc-pkgs/ghc-${ghc.version}"
|
2011-12-04 17:45:12 +00:00
|
|
|
# Check if current path is a Cabal package for the current GHC
|
|
|
|
if test -d $currentPkgDir; then
|
|
|
|
echo -n "Linking $currentPath "
|
2012-03-21 11:46:12 +00:00
|
|
|
for f in "$currentPath/bin/"*; do
|
2011-12-04 17:45:12 +00:00
|
|
|
ln -s $f $out/bin
|
|
|
|
echo -n .
|
|
|
|
done
|
2012-03-21 11:46:12 +00:00
|
|
|
for f in "$currentPkgDir/"*.conf; do
|
2011-12-04 17:45:12 +00:00
|
|
|
ln -s $f $linkedPkgDir
|
|
|
|
echo -n .
|
|
|
|
done
|
|
|
|
echo
|
|
|
|
fi
|
2011-12-03 16:19:43 +00:00
|
|
|
done
|
|
|
|
|
2011-12-04 17:45:12 +00:00
|
|
|
echo -n "Generating package cache "
|
2011-12-04 16:07:39 +00:00
|
|
|
${ghc}/bin/ghc-pkg --global-conf $linkedPkgDir recache
|
2011-12-04 17:45:12 +00:00
|
|
|
echo .
|
2011-12-03 16:19:43 +00:00
|
|
|
|
2011-12-04 16:07:39 +00:00
|
|
|
echo -n "Generating wrappers "
|
2011-12-03 16:19:43 +00:00
|
|
|
|
2011-12-04 16:07:39 +00:00
|
|
|
for prg in ghc ghci ghc-${ghc.version} ghci-${ghc.version}; do
|
|
|
|
makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "-B$linkedTopDir"
|
|
|
|
echo -n .
|
|
|
|
done
|
2011-12-03 16:19:43 +00:00
|
|
|
|
2011-12-04 16:07:39 +00:00
|
|
|
for prg in runghc runhaskell; do
|
|
|
|
makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "-f $out/bin/ghc"
|
|
|
|
echo -n .
|
2011-12-03 16:19:43 +00:00
|
|
|
done
|
|
|
|
|
2011-12-04 16:07:39 +00:00
|
|
|
for prg in ghc-pkg ghc-pkg-${ghc.version}; do
|
|
|
|
makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "--global-conf $linkedPkgDir"
|
|
|
|
echo -n .
|
|
|
|
done
|
2011-12-03 16:19:43 +00:00
|
|
|
|
2011-12-04 16:07:39 +00:00
|
|
|
for prg in hp2ps hpc hasktags hsc2hs haddock haddock-${ghc.version}; do
|
2011-12-04 17:45:12 +00:00
|
|
|
if test -x ${ghc}/bin/$prg -a ! -x $out/bin/$prg; then
|
|
|
|
ln -s ${ghc}/bin/$prg $out/bin/$prg && echo -n .
|
|
|
|
fi
|
2011-12-04 16:07:39 +00:00
|
|
|
done
|
|
|
|
echo
|
2011-12-03 16:19:43 +00:00
|
|
|
'';
|
|
|
|
|
2011-12-04 16:07:39 +00:00
|
|
|
meta = ghc.meta;
|
2011-12-03 16:19:43 +00:00
|
|
|
}
|