2015-01-23 00:10:08 +01:00
|
|
|
# Install not only the Hoogle library and executable, but also a local Hoogle
|
|
|
|
# database which provides "Source" links to all specified 'packages' -- or the
|
|
|
|
# current Haskell Platform if no custom package set is provided.
|
|
|
|
#
|
|
|
|
# It is intended to be used in config.nix similarly to:
|
|
|
|
#
|
|
|
|
# { packageOverrides = pkgs: rec {
|
|
|
|
#
|
|
|
|
# haskellPackages =
|
|
|
|
# let callPackage = pkgs.lib.callPackageWith haskellPackages;
|
|
|
|
# in pkgs.recurseIntoAttrs (pkgs.haskellPackages.override {
|
|
|
|
# extension = self: super: {
|
|
|
|
# hoogleLocal = pkgs.haskellPackages.hoogleLocal.override {
|
|
|
|
# packages = with pkgs.haskellPackages; [
|
|
|
|
# mmorph
|
|
|
|
# monadControl
|
|
|
|
# ];
|
|
|
|
# };
|
|
|
|
# };
|
|
|
|
# });
|
|
|
|
# }}
|
|
|
|
#
|
|
|
|
# This will build mmorph and monadControl, and have the hoogle installation
|
|
|
|
# refer to their documentation via symlink so they are not garbage collected.
|
|
|
|
|
2016-11-21 20:44:42 +01:00
|
|
|
{ lib, stdenv, hoogle, writeText, ghc
|
|
|
|
, packages
|
2015-01-23 00:10:08 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
inherit (stdenv.lib) optional;
|
|
|
|
wrapper = ./hoogle-local-wrapper.sh;
|
2016-02-01 05:00:43 +01:00
|
|
|
isGhcjs = ghc.isGhcjs or false;
|
2016-02-01 06:10:45 +01:00
|
|
|
opts = lib.optionalString;
|
2016-02-01 05:00:43 +01:00
|
|
|
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
|
2016-06-20 14:48:33 +02:00
|
|
|
then "${ghc.doc}/${docLibGlob}/prologue.txt"
|
2016-02-01 05:00:43 +01:00
|
|
|
else writeText "ghcjs-prologue.txt" ''
|
|
|
|
This index includes documentation for many Haskell modules.
|
|
|
|
'';
|
2016-11-21 20:44:42 +01:00
|
|
|
|
|
|
|
docPackages = lib.closePropagation packages;
|
|
|
|
|
2015-01-23 00:10:08 +01:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "hoogle-local-0.1";
|
2016-08-31 11:53:18 +02:00
|
|
|
buildInputs = [ghc hoogle];
|
2015-01-23 00:10:08 +01:00
|
|
|
|
2015-08-18 01:55:04 +02:00
|
|
|
phases = [ "buildPhase" ];
|
2015-01-23 00:10:08 +01:00
|
|
|
|
2016-11-21 20:44:42 +01:00
|
|
|
inherit docPackages;
|
2015-08-18 01:55:04 +02:00
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
mkdir -p $out/share/doc/hoogle
|
2015-01-23 00:10:08 +01:00
|
|
|
|
2015-08-18 01:55:04 +02:00
|
|
|
echo importing builtin packages
|
2016-06-20 21:52:20 +02:00
|
|
|
for docdir in ${ghc.doc}/${docLibGlob}/*; do
|
2016-02-01 06:10:45 +01:00
|
|
|
name="$(basename $docdir)"
|
|
|
|
${opts isGhcjs ''docdir="$docdir/html"''}
|
2015-08-18 01:55:04 +02:00
|
|
|
if [[ -d $docdir ]]; then
|
2016-02-01 06:10:45 +01:00
|
|
|
ln -sfn $docdir $out/share/doc/hoogle/$name
|
2015-08-18 01:55:04 +02:00
|
|
|
fi
|
2015-01-23 00:10:08 +01:00
|
|
|
done
|
|
|
|
|
2015-08-18 01:55:04 +02:00
|
|
|
echo importing other packages
|
2015-01-23 00:10:08 +01:00
|
|
|
for i in $docPackages; do
|
|
|
|
if [[ ! $i == $out ]]; then
|
2016-02-01 05:00:43 +01:00
|
|
|
for docdir in $i/share/doc/*-${ghcName}-*/* $i/share/doc/*; do
|
2016-08-31 11:53:18 +02:00
|
|
|
name="$(basename $docdir)"
|
2015-08-18 01:55:04 +02:00
|
|
|
docdir=$docdir/html
|
2015-01-23 00:10:08 +01:00
|
|
|
if [[ -d $docdir ]]; then
|
2015-08-18 01:55:04 +02:00
|
|
|
ln -sfn $docdir $out/share/doc/hoogle/$name
|
2015-01-23 00:10:08 +01:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2015-08-18 01:55:04 +02:00
|
|
|
echo building hoogle database
|
2016-08-31 11:53:18 +02:00
|
|
|
hoogle generate --database $out/share/doc/hoogle/default.hoo --local=$out/share/doc/hoogle
|
2015-01-23 00:10:08 +01:00
|
|
|
|
2015-08-18 01:55:04 +02:00
|
|
|
echo building haddock index
|
|
|
|
# adapted from GHC's gen_contents_index
|
|
|
|
cd $out/share/doc/hoogle
|
|
|
|
|
|
|
|
args=
|
|
|
|
for hdfile in `ls -1 */*.haddock | grep -v '/ghc\.haddock' | sort`
|
|
|
|
do
|
|
|
|
name_version=`echo "$hdfile" | sed 's#/.*##'`
|
|
|
|
args="$args --read-interface=$name_version,$hdfile"
|
|
|
|
done
|
|
|
|
|
2016-02-01 05:00:43 +01:00
|
|
|
${ghc}/bin/${haddockExe} --gen-index --gen-contents -o . \
|
2015-08-18 01:55:04 +02:00
|
|
|
-t "Haskell Hierarchical Libraries" \
|
2016-02-01 05:00:43 +01:00
|
|
|
-p ${prologue} \
|
2015-08-18 01:55:04 +02:00
|
|
|
$args
|
2015-01-23 00:10:08 +01:00
|
|
|
|
2015-08-18 01:55:04 +02:00
|
|
|
echo finishing up
|
2015-01-23 00:10:08 +01:00
|
|
|
mkdir -p $out/bin
|
|
|
|
substitute ${wrapper} $out/bin/hoogle \
|
|
|
|
--subst-var out --subst-var-by shell ${stdenv.shell} \
|
|
|
|
--subst-var-by hoogle ${hoogle}
|
|
|
|
chmod +x $out/bin/hoogle
|
|
|
|
'';
|
|
|
|
|
2015-08-17 21:45:13 +02:00
|
|
|
passthru = {
|
|
|
|
isHaskellLibrary = false; # for the filter in ./with-packages-wrapper.nix
|
|
|
|
};
|
|
|
|
|
2015-01-23 00:10:08 +01:00
|
|
|
meta = {
|
|
|
|
description = "A local Hoogle database";
|
|
|
|
platforms = ghc.meta.platforms;
|
|
|
|
hydraPlatforms = with stdenv.lib.platforms; none;
|
|
|
|
maintainers = with stdenv.lib.maintainers; [ ttuegel ];
|
|
|
|
};
|
|
|
|
}
|