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