about summary refs log tree commit diff
path: root/pkgs/development/compilers/ghc
diff options
context:
space:
mode:
authorAndres Löh <mail@andres-loeh.de>2009-04-25 14:23:00 +0000
committerAndres Löh <mail@andres-loeh.de>2009-04-25 14:23:00 +0000
commit66f3af0bdd87c8f3029aefcd3dd8f069cdbff5dc (patch)
treeef98e37e6b4c14e94654bae822c7eaf54ea98654 /pkgs/development/compilers/ghc
parentc26271927a94fd67554e476fb3e91bd043e5a95d (diff)
ghc-wrapper now detects installed pkgs automatically.
svn path=/nixpkgs/trunk/; revision=15301
Diffstat (limited to 'pkgs/development/compilers/ghc')
-rwxr-xr-xpkgs/development/compilers/ghc/ghc-get-packages.sh21
-rw-r--r--pkgs/development/compilers/ghc/setup-hook.sh17
-rw-r--r--pkgs/development/compilers/ghc/wrapper.nix21
3 files changed, 38 insertions, 21 deletions
diff --git a/pkgs/development/compilers/ghc/ghc-get-packages.sh b/pkgs/development/compilers/ghc/ghc-get-packages.sh
new file mode 100755
index 0000000000000..4593ead17d31b
--- /dev/null
+++ b/pkgs/development/compilers/ghc/ghc-get-packages.sh
@@ -0,0 +1,21 @@
+#! /bin/sh
+# Usage:
+#  $1: version of GHC
+#  $2: invocation path of GHC
+#  $3: prefix
+version="$1"
+if test -z "$3"; then
+  prefix="-package-conf "
+else
+  prefix="$3"
+fi
+PATH="$2:$PATH"
+IFS=":"
+PKGS=""
+for p in $PATH; do
+  PkgDir="$p/../lib/ghc-pkgs/ghc-$version"
+  for i in $PkgDir/*.installedconf; do
+    test -f $i && PKGS="$PKGS $prefix$i"
+  done
+done
+echo $PKGS
diff --git a/pkgs/development/compilers/ghc/setup-hook.sh b/pkgs/development/compilers/ghc/setup-hook.sh
deleted file mode 100644
index 11ad50a0c7963..0000000000000
--- a/pkgs/development/compilers/ghc/setup-hook.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-# Create isolated package config
-packages_db=$TMPDIR/.package.conf
-cp @ghc@/lib/ghc-*/package.conf $packages_db
-chmod u+w $packages_db
-
-export GHC_PACKAGE_PATH=$packages_db
-
-# Env hook to add packages to the package config
-addLibToPackageConf () {
-    local fn
-    shopt -s nullglob
-    for fn in $1/lib/ghc-pkgs/ghc-@ghcVersion@/*.conf; do
-        @ghc@/bin/ghc-pkg register --force $fn
-    done
-}
-
-envHooks=(${envHooks[@]} addLibToPackageConf)
diff --git a/pkgs/development/compilers/ghc/wrapper.nix b/pkgs/development/compilers/ghc/wrapper.nix
index 932cf63430181..5cacfdf8f894f 100644
--- a/pkgs/development/compilers/ghc/wrapper.nix
+++ b/pkgs/development/compilers/ghc/wrapper.nix
@@ -1,14 +1,27 @@
-{stdenv, ghc}:
+{stdenv, ghc, makeWrapper}:
 
 stdenv.mkDerivation {
-  name = "ghc-wrapper-${ghc.version}";
+  name = "ghc-${ghc.version}-wrapper";
 
+  buildInputs = [makeWrapper];
   propagatedBuildInputs = [ghc];
 
   unpackPhase = "true";
-  installPhase = "true";
+  installPhase = ''
+    ensureDir $out/bin
+    cp $GHCGetPackages $out/bin/ghc-get-packages.sh
+    chmod 755 $out/bin/ghc-get-packages.sh
+    for prg in ghc ghci ghc-${ghc.version} ghci-${ghc.version} runghc runhaskell; do
+      makeWrapper $ghc/bin/$prg $out/bin/$prg --add-flags "\$($out/bin/ghc-get-packages.sh ${ghc.version} \"\$(dirname \$0)\")"
+    done
+    for prg in ghc-pkg ghc-pkg-${ghc.version}; do
+      makeWrapper $ghc/bin/$prg $out/bin/$prg --add-flags "\$($out/bin/ghc-get-packages.sh ${ghc.version} \"\$(dirname \$0)\" --package-conf=)"
+    done
+    ensureDir $out/nix-support
+    ln -s $out/nix-support/propagated-build-inputs $out/nix-support/propagated-user-env-packages
+  ''; 
   
-  setupHook = ./setup-hook.sh;
+  GHCGetPackages = ./ghc-get-packages.sh;
 
   inherit ghc;
   ghcVersion = ghc.version;