3
0
Fork 0
forked from mirrors/nixpkgs

Merge pull request #27991 from Profpatsch/hoogleLocal-fix

Fix the `ghcWithHoogle` function to cope with the presence of separate `doc` outputs.
This commit is contained in:
Peter Simons 2017-08-19 16:26:30 +02:00 committed by GitHub
commit 5468d5c662
4 changed files with 35 additions and 17 deletions

View file

@ -36,7 +36,7 @@ self: super: {
jailbreak-cabal = (disableSharedExecutables super.jailbreak-cabal).override { Cabal = self.Cabal_1_20_0_4; }; jailbreak-cabal = (disableSharedExecutables super.jailbreak-cabal).override { Cabal = self.Cabal_1_20_0_4; };
# enable using a local hoogle with extra packagages in the database # enable using a local hoogle with extra packagages in the database
# nix-shell -p "haskellPackages.hoogleLocal (with haskellPackages; [ mtl lens ])" # nix-shell -p "haskellPackages.hoogleLocal { packages = with haskellPackages; [ mtl lens ]; }"
# $ hoogle server # $ hoogle server
hoogleLocal = { packages ? [] }: self.callPackage ./hoogle.nix { inherit packages; }; hoogleLocal = { packages ? [] }: self.callPackage ./hoogle.nix { inherit packages; };

View file

@ -1,6 +1,7 @@
{ stdenv, fetchurl, ghc, pkgconfig, glibcLocales, coreutils, gnugrep, gnused { stdenv, fetchurl, ghc, pkgconfig, glibcLocales, coreutils, gnugrep, gnused
, jailbreak-cabal, hscolour, cpphs, nodejs, lib, removeReferencesTo , jailbreak-cabal, hscolour, cpphs, nodejs, lib, removeReferencesTo
}: let isCross = (ghc.cross or null) != null; in }:
let isCross = (ghc.cross or null) != null; in
{ pname { pname
, dontStrip ? (ghc.isGhcjs or false) , dontStrip ? (ghc.isGhcjs or false)
@ -78,6 +79,9 @@ let
then "package-db" then "package-db"
else "package-conf"; else "package-conf";
# the target dir for haddock documentation
docdir = docoutput: docoutput + "/share/doc";
newCabalFileUrl = "http://hackage.haskell.org/package/${pname}-${version}/revision/${revision}.cabal"; newCabalFileUrl = "http://hackage.haskell.org/package/${pname}-${version}/revision/${revision}.cabal";
newCabalFile = fetchurl { newCabalFile = fetchurl {
url = newCabalFileUrl; url = newCabalFileUrl;
@ -111,7 +115,7 @@ let
defaultConfigureFlags = [ defaultConfigureFlags = [
"--verbose" "--prefix=$out" "--libdir=\\$prefix/lib/\\$compiler" "--libsubdir=\\$pkgid" "--verbose" "--prefix=$out" "--libdir=\\$prefix/lib/\\$compiler" "--libsubdir=\\$pkgid"
(optionalString enableSeparateDataOutput "--datadir=$data/share/${ghc.name}") (optionalString enableSeparateDataOutput "--datadir=$data/share/${ghc.name}")
(optionalString enableSeparateDocOutput "--docdir=$doc/share/doc") (optionalString enableSeparateDocOutput "--docdir=${docdir "$doc"}")
"--with-gcc=$CC" # Clang won't work without that extra information. "--with-gcc=$CC" # Clang won't work without that extra information.
"--package-db=$packageConfDir" "--package-db=$packageConfDir"
(optionalString (enableSharedExecutables && stdenv.isLinux) "--ghc-option=-optl=-Wl,-rpath=$out/lib/${ghc.name}/${pname}-${version}") (optionalString (enableSharedExecutables && stdenv.isLinux) "--ghc-option=-optl=-Wl,-rpath=$out/lib/${ghc.name}/${pname}-${version}")
@ -331,7 +335,7 @@ stdenv.mkDerivation ({
''} ''}
${optionalString enableSeparateDocOutput '' ${optionalString enableSeparateDocOutput ''
for x in $doc/share/doc/html/src/*.html; do for x in ${docdir "$doc"}/html/src/*.html; do
remove-references-to -t $out $x remove-references-to -t $out $x
done done
mkdir -p $doc mkdir -p $doc
@ -347,6 +351,14 @@ stdenv.mkDerivation ({
isHaskellLibrary = hasActiveLibrary; isHaskellLibrary = hasActiveLibrary;
# TODO: ask why the split outputs are configurable at all?
# TODO: include tests for split if possible
# Given the haskell package, returns
# the directory containing the haddock documentation.
# `null' if no haddock documentation was built.
# TODO: fetch the self from the fixpoint instead
haddockDir = self: if doHaddock then "${docdir self.doc}/html" else null;
env = stdenv.mkDerivation { env = stdenv.mkDerivation {
name = "interactive-${pname}-${version}-environment"; name = "interactive-${pname}-${version}-environment";
nativeBuildInputs = [ ghcEnv systemBuildInputs ] nativeBuildInputs = [ ghcEnv systemBuildInputs ]
@ -356,6 +368,7 @@ stdenv.mkDerivation ({
shellHook = '' shellHook = ''
export NIX_${ghcCommandCaps}="${ghcEnv}/bin/${ghcCommand}" export NIX_${ghcCommandCaps}="${ghcEnv}/bin/${ghcCommand}"
export NIX_${ghcCommandCaps}PKG="${ghcEnv}/bin/${ghcCommand}-pkg" export NIX_${ghcCommandCaps}PKG="${ghcEnv}/bin/${ghcCommand}-pkg"
# TODO: is this still valid?
export NIX_${ghcCommandCaps}_DOCDIR="${ghcEnv}/share/doc/ghc/html" export NIX_${ghcCommandCaps}_DOCDIR="${ghcEnv}/share/doc/ghc/html"
export LD_LIBRARY_PATH="''${LD_LIBRARY_PATH:+''${LD_LIBRARY_PATH}:}${ export LD_LIBRARY_PATH="''${LD_LIBRARY_PATH:+''${LD_LIBRARY_PATH}:}${
makeLibraryPath (filter (x: !isNull x) systemBuildInputs) makeLibraryPath (filter (x: !isNull x) systemBuildInputs)

View file

@ -52,7 +52,10 @@ let
This index includes documentation for many Haskell modules. This index includes documentation for many Haskell modules.
''; '';
docPackages = lib.closePropagation packages; # TODO: closePropagation is deprecated; replace
docPackages = lib.closePropagation
# we grab the doc outputs
(map (lib.getOutput "doc") packages);
in in
stdenv.mkDerivation { stdenv.mkDerivation {
@ -64,6 +67,10 @@ stdenv.mkDerivation {
inherit docPackages; inherit docPackages;
buildPhase = '' buildPhase = ''
${lib.optionalString (packages != [] -> docPackages == [])
("echo WARNING: localHoogle package list empty, even though"
+ " the following were specified: "
+ lib.concatMapStringsSep ", " (p: p.name) packages)}
mkdir -p $out/share/doc/hoogle mkdir -p $out/share/doc/hoogle
echo importing builtin packages echo importing builtin packages
@ -76,17 +83,13 @@ stdenv.mkDerivation {
done done
echo importing other packages echo importing other packages
for i in $docPackages; do ${lib.concatMapStringsSep "\n" (el: ''
if [[ ! $i == $out ]]; then ln -sfn ${el.haddockDir} "$out/share/doc/hoogle/${el.name}"
for docdir in $i/share/doc/*-${ghcName}-*/* $i/share/doc/*; do '')
name="$(basename $docdir)" (lib.filter (el: el.haddockDir != null)
docdir=$docdir/html (builtins.map (p: { haddockDir = p.haddockDir p;
if [[ -d $docdir ]]; then name = p.pname; })
ln -sfn $docdir $out/share/doc/hoogle/$name docPackages))}
fi
done
fi
done
echo building hoogle database echo building hoogle database
hoogle generate --database $out/share/doc/hoogle/default.hoo --local=$out/share/doc/hoogle hoogle generate --database $out/share/doc/hoogle/default.hoo --local=$out/share/doc/hoogle

View file

@ -25,7 +25,9 @@
}: }:
# return value: a function from self to the package set # return value: a function from self to the package set
self: let self:
let
inherit (stdenv.lib) fix' extends makeOverridable; inherit (stdenv.lib) fix' extends makeOverridable;
inherit (haskellLib) overrideCabal; inherit (haskellLib) overrideCabal;