From ecf037f2f7fa2aa956e582296cb06af093f3e4db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andres=20L=C3=B6h?= Date: Sat, 3 Dec 2011 16:19:43 +0000 Subject: [PATCH] Added a wrapper function to produce a GHC with a predefined set of packages. svn path=/nixpkgs/trunk/; revision=30716 --- .../compilers/ghc/with-packages.nix | 67 +++++++++++++++++++ pkgs/top-level/haskell-packages.nix | 9 +++ 2 files changed, 76 insertions(+) create mode 100644 pkgs/development/compilers/ghc/with-packages.nix diff --git a/pkgs/development/compilers/ghc/with-packages.nix b/pkgs/development/compilers/ghc/with-packages.nix new file mode 100644 index 00000000000..2535e28ebc1 --- /dev/null +++ b/pkgs/development/compilers/ghc/with-packages.nix @@ -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; +} diff --git a/pkgs/top-level/haskell-packages.nix b/pkgs/top-level/haskell-packages.nix index 1d99fd42aaf..7a62eb070eb 100644 --- a/pkgs/top-level/haskell-packages.nix +++ b/pkgs/top-level/haskell-packages.nix @@ -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.