nixpkgs/pkgs/development/compilers/ghc/wrapper.nix
Marc Weber 58239ae82a ghc: add ghc-packages returning list of package databases so that you
can define GHC_PACKAGE_PATH=`ghc-packgaes` easily. Required for scion

svn path=/nixpkgs/trunk/; revision=16481
2009-07-27 16:05:44 +00:00

49 lines
1.6 KiB
Nix

{stdenv, ghc, makeWrapper}:
stdenv.mkDerivation {
name = "ghc-${ghc.version}-wrapper";
buildInputs = [makeWrapper];
propagatedBuildInputs = [ghc];
unpackPhase = "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}; do
makeWrapper $ghc/bin/$prg $out/bin/$prg --add-flags "\$($out/bin/ghc-get-packages.sh ${ghc.version} \"\$(dirname \$0)\")"
done
for prg in runghc runhaskell; do
makeWrapper $ghc/bin/$prg $out/bin/$prg --add-flags "\$($out/bin/ghc-get-packages.sh ${ghc.version} \"\$(dirname \$0)\" \" -package-conf --ghc-arg=\")"
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
cat >> $out/bin/ghc-packages << EOF
#! /bin/bash -e
declare -A GHC_PACKAGES_HASH # using bash4 hashs to get uniq paths
for arg in \$($out/bin/ghc-get-packages.sh 6.10.3 "$(dirname $0)"); do
case "\$arg" in
-package-conf) ;;
*)
CANONICALIZED="\$(readlink -f "\$arg")"
GHC_PACKAGES_HASH["\$CANONICALIZED"]= ;;
esac
done
for path in \''${!GHC_PACKAGES_HASH[@]}; do
echo -n "\$path:"
done
EOF
chmod +x $out/bin/ghc-packages
ensureDir $out/nix-support
ln -s $out/nix-support/propagated-build-inputs $out/nix-support/propagated-user-env-packages
'';
GHCGetPackages = ./ghc-get-packages.sh;
inherit ghc;
ghcVersion = ghc.version;
}