2007-10-19 13:24:29 +00:00
|
|
|
# Support dir for isolating GHC
|
2008-01-09 13:08:36 +00:00
|
|
|
ghc_support=$TMPDIR/ghc-6.8-nix-support
|
2007-10-19 13:24:29 +00:00
|
|
|
mkdir -p $ghc_support
|
|
|
|
|
|
|
|
# Create isolated package config
|
|
|
|
packages_db=$ghc_support/package.conf
|
2008-02-22 18:19:04 +00:00
|
|
|
cp @out@/lib/ghc-*/package.conf $packages_db
|
2007-10-19 13:24:29 +00:00
|
|
|
chmod +w $packages_db
|
|
|
|
|
|
|
|
# Generate wrappers for GHC that use the isolated package config
|
|
|
|
makeWrapper() {
|
|
|
|
wrapperName="$1"
|
|
|
|
wrapper="$ghc_support/$wrapperName"
|
|
|
|
shift #the other arguments are passed to the source app
|
|
|
|
echo '#!'"$SHELL" > "$wrapper"
|
2008-03-14 14:49:17 +00:00
|
|
|
echo "exec \"@out@/bin/$wrapperName\" $@" '"$@"' >> "$wrapper"
|
2007-10-19 13:24:29 +00:00
|
|
|
chmod +x "$wrapper"
|
|
|
|
}
|
|
|
|
|
|
|
|
makeWrapper "ghc" "-no-user-package-conf -package-conf $packages_db"
|
|
|
|
makeWrapper "ghci" "-no-user-package-conf -package-conf $packages_db"
|
|
|
|
makeWrapper "runghc" "-no-user-package-conf -package-conf $packages_db"
|
|
|
|
makeWrapper "runhaskell" "-no-user-package-conf -package-conf $packages_db"
|
|
|
|
makeWrapper "ghc-pkg" "--global-conf $packages_db"
|
|
|
|
|
|
|
|
# Add wrappers to search path
|
|
|
|
export _PATH=$ghc_support:$_PATH
|
|
|
|
|
|
|
|
# Env hook to add packages to the package config
|
|
|
|
addLibToPackageConf ()
|
|
|
|
{
|
|
|
|
local regscript=$1/nix-support/register-ghclib.sh
|
|
|
|
if test -f $regscript; then
|
|
|
|
local oldpath=$PATH
|
|
|
|
export PATH=$ghc_support:$PATH
|
|
|
|
sh $regscript $package_db
|
|
|
|
export PATH=$oldpath
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
envHooks=(${envHooks[@]} addLibToPackageConf)
|