ghc-wrapper now detects installed pkgs automatically.

svn path=/nixpkgs/trunk/; revision=15301
This commit is contained in:
Andres Löh 2009-04-25 14:23:00 +00:00
parent c26271927a
commit 66f3af0bdd
5 changed files with 49 additions and 24 deletions

View file

@ -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

View file

@ -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)

View file

@ -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;

View file

@ -68,9 +68,17 @@ attrs :
./Setup copy
ensureDir $out/bin # necessary to get it added to PATH
local confDir=$out/lib/ghc-pkgs/ghc-${attrs.ghc.ghc.version}
local installedPkgConf=$confDir/${self.fname}.installedconf
local pkgConf=$confDir/${self.fname}.conf
ensureDir $confDir
./Setup register --gen-pkg-config=$confDir/${self.fname}.conf
./Setup register --gen-pkg-config=$pkgConf
if test -f $pkgConf; then
echo '[]' > $installedPkgConf
GHC_PACKAGE_PATH=$installedPkgConf ghc-pkg --global register $pkgConf --force
fi
ensureDir $out/nix-support
ln -s $out/nix-support/propagated-build-inputs $out/nix-support/propagated-user-env-packages

View file

@ -1,6 +1,6 @@
{pkgs, ghc}:
let ghcReal = ghc; in
let ghcReal = pkgs.lowPrio ghc; in
rec {
@ -11,7 +11,7 @@ rec {
# wrapper provides essential functionality: the ability to find
# Haskell packages in the buildInputs automatically.
ghc = import ../development/compilers/ghc/wrapper.nix {
inherit (pkgs) stdenv;
inherit (pkgs) stdenv makeWrapper;
ghc = ghcReal;
};