summary refs log tree commit diff
path: root/pkgs/development/compilers/ghc
diff options
context:
space:
mode:
authorAndres Löh <mail@andres-loeh.de>2011-12-03 16:19:43 +0000
committerAndres Löh <mail@andres-loeh.de>2011-12-03 16:19:43 +0000
commitecf037f2f7fa2aa956e582296cb06af093f3e4db (patch)
treef4d237fe483fc5fa2439991075e6209e8f3e19b9 /pkgs/development/compilers/ghc
parent72e5c8176e7a1ac2e9d2094ec21e90af225fe5bf (diff)
downloadnixpkgs-ecf037f2f7fa2aa956e582296cb06af093f3e4db.tar
nixpkgs-ecf037f2f7fa2aa956e582296cb06af093f3e4db.tar.gz
nixpkgs-ecf037f2f7fa2aa956e582296cb06af093f3e4db.tar.bz2
nixpkgs-ecf037f2f7fa2aa956e582296cb06af093f3e4db.tar.lz
nixpkgs-ecf037f2f7fa2aa956e582296cb06af093f3e4db.tar.xz
nixpkgs-ecf037f2f7fa2aa956e582296cb06af093f3e4db.tar.zst
nixpkgs-ecf037f2f7fa2aa956e582296cb06af093f3e4db.zip
Added a wrapper function to produce a GHC with a predefined set of packages.
svn path=/nixpkgs/trunk/; revision=30716
Diffstat (limited to 'pkgs/development/compilers/ghc')
-rw-r--r--pkgs/development/compilers/ghc/with-packages.nix67
1 files changed, 67 insertions, 0 deletions
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;
+}