ghcWithHoogle: add support for ghcjs

This commit is contained in:
Charles Strahan 2016-01-31 23:00:43 -05:00
parent 05b2afed33
commit 1a2d7c679a

View File

@ -23,13 +23,33 @@
# This will build mmorph and monadControl, and have the hoogle installation
# refer to their documentation via symlink so they are not garbage collected.
{ lib, stdenv, hoogle, rehoo
{ lib, stdenv, hoogle, rehoo, writeText
, ghc, packages ? [ ghc.ghc ]
}:
let
inherit (stdenv.lib) optional;
wrapper = ./hoogle-local-wrapper.sh;
isGhcjs = ghc.isGhcjs or false;
haddockExe =
if !isGhcjs
then "haddock"
else "haddock-ghcjs";
ghcName =
if !isGhcjs
then "ghc"
else "ghcjs";
docLibGlob =
if !isGhcjs
then ''share/doc/ghc*/html/libraries''
else ''doc/lib'';
# On GHCJS, use a stripped down version of GHC's prologue.txt
prologue =
if !isGhcjs
then "${ghc}/${docLibGlob}/prologue.txt"
else writeText "ghcjs-prologue.txt" ''
This index includes documentation for many Haskell modules.
'';
in
stdenv.mkDerivation {
name = "hoogle-local-0.1";
@ -58,7 +78,7 @@ stdenv.mkDerivation {
}
echo importing builtin packages
for docdir in ${ghc}/share/doc/ghc*/html/libraries/*; do
for docdir in ${ghc}/${docLibGlob}/*; do
if [[ -d $docdir ]]; then
import_dbs $docdir
ln -sfn $docdir $out/share/doc/hoogle
@ -68,7 +88,7 @@ stdenv.mkDerivation {
echo importing other packages
for i in $docPackages; do
if [[ ! $i == $out ]]; then
for docdir in $i/share/doc/*-ghc-*/* $i/share/doc/*; do
for docdir in $i/share/doc/*-${ghcName}-*/* $i/share/doc/*; do
name=`basename $docdir`
docdir=$docdir/html
if [[ -d $docdir ]]; then
@ -99,9 +119,9 @@ stdenv.mkDerivation {
args="$args --read-interface=$name_version,$hdfile"
done
${ghc}/bin/haddock --gen-index --gen-contents -o . \
${ghc}/bin/${haddockExe} --gen-index --gen-contents -o . \
-t "Haskell Hierarchical Libraries" \
-p ${ghc}/share/doc/ghc*/html/libraries/prologue.txt \
-p ${prologue} \
$args
echo finishing up