Added a wrapper function to produce a GHC with a predefined set of packages.

svn path=/nixpkgs/trunk/; revision=30716
This commit is contained in:
Andres Löh 2011-12-03 16:19:43 +00:00
parent 72e5c8176e
commit ecf037f2f7
2 changed files with 76 additions and 0 deletions

View File

@ -0,0 +1,67 @@
{stdenv, ghcPlain, packages ? [], makeWrapper}:
stdenv.mkDerivation rec {
name = "ghc-${ghcPlain.version}-linkdir";
allPackages = stdenv.lib.closePropagation packages;
buildInputs = allPackages ++ [makeWrapper];
propagatedBuildInputs = packages;
unpackPhase = "true";
installPhase = ''
originalTopDir="${ghcPlain}/lib/ghc-${ghcPlain.version}"
originalPkgDir="$originalTopDir/package.conf.d"
linkedTopDir="$out/lib"
linkedPkgDir="$linkedTopDir/package.conf.d"
ensureDir $out/bin
cd $out/bin
echo "Generating wrappers ..."
for prg in ghc ghci ghc-${ghcPlain.version} ghci-${ghcPlain.version}; do
makeWrapper ${ghcPlain}/bin/$prg $out/bin/$prg --add-flags "-B$linkedTopDir"
done
for prg in runghc runhaskell; do
makeWrapper ${ghcPlain}/bin/$prg $out/bin/$prg --add-flags "-f $out/bin/ghc"
done
for prg in ghc-pkg ghc-pkg-${ghcPlain.version}; do
makeWrapper ${ghcPlain}/bin/$prg $out/bin/$prg --add-flags "--global-conf $linkedPkgDir"
done
for prg in hp2ps hpc hasktags hsc2hs haddock haddock-${ghcPlain.version}; do
test -x ${ghcPlain}/bin/$prg && ln -s ${ghcPlain}/bin/$prg $out/bin/$prg
done
ensureDir $linkedTopDir
cd $linkedTopDir
if test -f $originalTopDir/settings; then
echo "Linking $originalTopDir/settings ..."
ln -s $originalTopDir/settings .
fi
ensureDir $linkedPkgDir
cd $linkedPkgDir
echo "Linking $originalPkgDir ..."
ln -s $originalPkgDir/*.conf .
for currentPath in ${stdenv.lib.concatStringsSep " " allPackages}; do
currentPkgDir="$currentPath/lib/ghc-pkgs/ghc-${ghcPlain.version}"
if test -d $currentPkgDir; then
echo "Linking $currentPkgDir ..."
ln -s $currentPkgDir/*.conf .
fi
done
echo "Generating package cache ..."
${ghcPlain}/bin/ghc-pkg --global-conf $linkedPkgDir recache
'';
# inherit ghc.meta;
}

View File

@ -107,6 +107,15 @@ let result = let callPackage = x : y : modifyPrio (newScope result.final x y);
ghc = ghc;
};
# An experimental wrapper around ghcPlain that does not automatically
# pick up packages from the profile, but instead has a fixed set of packages
# in its global database. The set of packages can be specified as an
# argument to this function.
ghcWithPackages = pkgs : callPackage ../development/compilers/ghc/with-packages.nix {
packages = pkgs self;
};
# This is the Cabal builder, the function we use to build most Haskell
# packages. It isn't the Cabal library, which is a core package of GHC
# and therefore not separately listed here.