2009-04-25 15:23:00 +01:00
|
|
|
{stdenv, ghc, makeWrapper}:
|
2009-04-18 13:47:11 +01:00
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
2009-04-25 15:23:00 +01:00
|
|
|
name = "ghc-${ghc.version}-wrapper";
|
2009-04-18 13:47:11 +01:00
|
|
|
|
2009-04-25 15:23:00 +01:00
|
|
|
buildInputs = [makeWrapper];
|
2009-04-18 13:47:11 +01:00
|
|
|
propagatedBuildInputs = [ghc];
|
|
|
|
|
|
|
|
unpackPhase = "true";
|
2009-04-25 15:23:00 +01:00
|
|
|
installPhase = ''
|
|
|
|
ensureDir $out/bin
|
|
|
|
cp $GHCGetPackages $out/bin/ghc-get-packages.sh
|
|
|
|
chmod 755 $out/bin/ghc-get-packages.sh
|
2009-05-28 20:06:29 +01:00
|
|
|
for prg in ghc ghci ghc-${ghc.version} ghci-${ghc.version}; do
|
2009-04-25 15:23:00 +01:00
|
|
|
makeWrapper $ghc/bin/$prg $out/bin/$prg --add-flags "\$($out/bin/ghc-get-packages.sh ${ghc.version} \"\$(dirname \$0)\")"
|
|
|
|
done
|
2009-05-28 20:06:29 +01:00
|
|
|
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
|
2009-04-25 15:23:00 +01:00
|
|
|
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
|
2010-04-29 18:35:05 +01:00
|
|
|
for prg in hp2ps hpc hasktags hsc2hs; do
|
|
|
|
test -x $ghc/bin/$prg && ln -s $ghc/bin/$prg $out/bin/$prg
|
|
|
|
done
|
2009-07-27 17:05:44 +01:00
|
|
|
cat >> $out/bin/ghc-packages << EOF
|
|
|
|
#! /bin/bash -e
|
|
|
|
declare -A GHC_PACKAGES_HASH # using bash4 hashs to get uniq paths
|
|
|
|
|
2009-11-12 07:11:03 +00:00
|
|
|
for arg in \$($out/bin/ghc-get-packages.sh ${ghc.version} \"\$(dirname \$0)\"); do
|
2009-07-27 17:05:44 +01:00
|
|
|
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
|
2009-04-25 15:23:00 +01:00
|
|
|
ensureDir $out/nix-support
|
|
|
|
ln -s $out/nix-support/propagated-build-inputs $out/nix-support/propagated-user-env-packages
|
2011-08-16 14:03:38 +01:00
|
|
|
'';
|
|
|
|
|
2009-04-25 15:23:00 +01:00
|
|
|
GHCGetPackages = ./ghc-get-packages.sh;
|
2009-04-18 13:47:11 +01:00
|
|
|
|
|
|
|
inherit ghc;
|
2010-04-26 21:39:51 +01:00
|
|
|
inherit (ghc) meta;
|
2009-04-18 21:24:36 +01:00
|
|
|
ghcVersion = ghc.version;
|
2009-04-18 13:47:11 +01:00
|
|
|
}
|