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 # This will build mmorph and monadControl, and have the hoogle installation
# refer to their documentation via symlink so they are not garbage collected. # 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 ] , ghc, packages ? [ ghc.ghc ]
}: }:
let let
inherit (stdenv.lib) optional; inherit (stdenv.lib) optional;
wrapper = ./hoogle-local-wrapper.sh; 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 in
stdenv.mkDerivation { stdenv.mkDerivation {
name = "hoogle-local-0.1"; name = "hoogle-local-0.1";
@ -58,7 +78,7 @@ stdenv.mkDerivation {
} }
echo importing builtin packages echo importing builtin packages
for docdir in ${ghc}/share/doc/ghc*/html/libraries/*; do for docdir in ${ghc}/${docLibGlob}/*; do
if [[ -d $docdir ]]; then if [[ -d $docdir ]]; then
import_dbs $docdir import_dbs $docdir
ln -sfn $docdir $out/share/doc/hoogle ln -sfn $docdir $out/share/doc/hoogle
@ -68,7 +88,7 @@ stdenv.mkDerivation {
echo importing other packages echo importing other packages
for i in $docPackages; do for i in $docPackages; do
if [[ ! $i == $out ]]; then 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` name=`basename $docdir`
docdir=$docdir/html docdir=$docdir/html
if [[ -d $docdir ]]; then if [[ -d $docdir ]]; then
@ -99,9 +119,9 @@ stdenv.mkDerivation {
args="$args --read-interface=$name_version,$hdfile" args="$args --read-interface=$name_version,$hdfile"
done done
${ghc}/bin/haddock --gen-index --gen-contents -o . \ ${ghc}/bin/${haddockExe} --gen-index --gen-contents -o . \
-t "Haskell Hierarchical Libraries" \ -t "Haskell Hierarchical Libraries" \
-p ${ghc}/share/doc/ghc*/html/libraries/prologue.txt \ -p ${prologue} \
$args $args
echo finishing up echo finishing up