haskell-packages: make hoogle wrapper much more helpful
* Build most of the stuff on /tmp, not in /nix/store. * Generate hoogle database for all the dependencies. * Generate haddock index and contents files. * Cleanup.
This commit is contained in:
parent
d8487667cf
commit
0013743845
@ -2,5 +2,4 @@
|
|||||||
|
|
||||||
COMMAND=$1
|
COMMAND=$1
|
||||||
shift
|
shift
|
||||||
HOOGLE_DOC_PATH=@out@/share/hoogle/doc exec @hoogle@/bin/hoogle \
|
exec @hoogle@/bin/hoogle "$COMMAND" -d @out@/share/doc/hoogle "$@"
|
||||||
"$COMMAND" -d @out@/share/hoogle "$@"
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
# 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.
|
||||||
|
|
||||||
{ stdenv, hoogle, rehoo
|
{ lib, stdenv, hoogle, rehoo
|
||||||
, ghc, packages ? [ ghc.ghc ]
|
, ghc, packages ? [ ghc.ghc ]
|
||||||
}:
|
}:
|
||||||
|
|
||||||
@ -35,62 +35,76 @@ stdenv.mkDerivation {
|
|||||||
name = "hoogle-local-0.1";
|
name = "hoogle-local-0.1";
|
||||||
buildInputs = [hoogle rehoo];
|
buildInputs = [hoogle rehoo];
|
||||||
|
|
||||||
phases = [ "installPhase" ];
|
phases = [ "buildPhase" ];
|
||||||
|
|
||||||
docPackages = packages;
|
docPackages = (lib.closePropagation packages);
|
||||||
installPhase = ''
|
|
||||||
|
buildPhase = ''
|
||||||
if [ -z "$docPackages" ]; then
|
if [ -z "$docPackages" ]; then
|
||||||
echo "ERROR: The packages attribute has not been set"
|
echo "ERROR: The packages attribute has not been set"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p $out/share/hoogle/doc
|
mkdir -p $out/share/doc/hoogle
|
||||||
export HOOGLE_DOC_PATH=$out/share/hoogle/doc
|
|
||||||
|
|
||||||
cd $out/share/hoogle
|
|
||||||
|
|
||||||
function import_dbs() {
|
function import_dbs() {
|
||||||
find $1 -name '*.txt' | while read f; do
|
find $1 -name '*.txt' | while read f; do
|
||||||
newname=$(basename "$f" | tr '[:upper:]' '[:lower:]')
|
newname=$(basename "$f" | tr '[:upper:]' '[:lower:]')
|
||||||
if [[ -f $f && ! -f ./$newname ]]; then
|
if [[ -f $f && ! -f ./$newname ]]; then
|
||||||
cp -p $f ./$newname
|
cp -p $f "./$newname"
|
||||||
hoogle convert -d "$(dirname $f)" "./$newname"
|
hoogle convert -d "$(dirname $f)" "./$newname"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
for i in $docPackages; do
|
echo importing builtin packages
|
||||||
findInputs $i docPackages propagated-native-build-inputs
|
for docdir in ${ghc}/share/doc/ghc*/html/libraries/*; do
|
||||||
findInputs $i docPackages propagated-build-inputs
|
if [[ -d $docdir ]]; then
|
||||||
|
import_dbs $docdir
|
||||||
|
ln -sfn $docdir $out/share/doc/hoogle
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
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/*-ghc-*/* $i/share/doc/*; do
|
||||||
|
name=`basename $docdir`
|
||||||
|
docdir=$docdir/html
|
||||||
if [[ -d $docdir ]]; then
|
if [[ -d $docdir ]]; then
|
||||||
import_dbs $docdir
|
import_dbs $docdir
|
||||||
ln -sf $docdir $out/share/hoogle/doc
|
ln -sfn $docdir $out/share/doc/hoogle/$name
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
import_dbs ${ghc}/share/doc/ghc*/html/libraries
|
echo building hoogle database
|
||||||
ln -sf ${ghc}/share/doc/ghc*/html/libraries/* $out/share/hoogle/doc
|
# FIXME: rehoo is marked as depricated on Hackage
|
||||||
|
|
||||||
chmod 644 *.hoo *.txt
|
chmod 644 *.hoo *.txt
|
||||||
rehoo -j4 -c64 .
|
rehoo -j4 -c64 .
|
||||||
|
|
||||||
rm -fr downloads *.dep *.txt
|
mv default.hoo .x
|
||||||
mv default.hoo x || exit 0
|
rm -fr downloads *.dep *.txt *.hoo
|
||||||
rm -f *.hoo
|
mv .x $out/share/doc/hoogle/default.hoo
|
||||||
mv x default.hoo || exit 1
|
|
||||||
|
|
||||||
if [ ! -f default.hoo ]; then
|
echo building haddock index
|
||||||
echo "Unable to build the default Hoogle database"
|
# adapted from GHC's gen_contents_index
|
||||||
exit 1
|
cd $out/share/doc/hoogle
|
||||||
fi
|
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
${ghc}/bin/haddock --gen-index --gen-contents -o . \
|
||||||
|
-t "Haskell Hierarchical Libraries" \
|
||||||
|
-p ${ghc}/share/doc/ghc*/html/libraries/prologue.txt \
|
||||||
|
$args
|
||||||
|
|
||||||
|
echo finishing up
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
substitute ${wrapper} $out/bin/hoogle \
|
substitute ${wrapper} $out/bin/hoogle \
|
||||||
--subst-var out --subst-var-by shell ${stdenv.shell} \
|
--subst-var out --subst-var-by shell ${stdenv.shell} \
|
||||||
|
@ -85,6 +85,7 @@ rec {
|
|||||||
withHoogle = haskellEnv: with haskellEnv.haskellPackages;
|
withHoogle = haskellEnv: with haskellEnv.haskellPackages;
|
||||||
import ./hoogle.nix {
|
import ./hoogle.nix {
|
||||||
inherit (pkgs) stdenv;
|
inherit (pkgs) stdenv;
|
||||||
|
inherit (pkgs.stdenv) lib;
|
||||||
inherit hoogle rehoo ghc;
|
inherit hoogle rehoo ghc;
|
||||||
packages = haskellEnv.paths;
|
packages = haskellEnv.paths;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user