diff --git a/pkgs/development/haskell-modules/configuration-common.nix b/pkgs/development/haskell-modules/configuration-common.nix index fc39b62402a..8ab751166c5 100644 --- a/pkgs/development/haskell-modules/configuration-common.nix +++ b/pkgs/development/haskell-modules/configuration-common.nix @@ -36,7 +36,7 @@ self: super: { 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 - # nix-shell -p "haskellPackages.hoogleLocal (with haskellPackages; [ mtl lens ])" + # nix-shell -p "haskellPackages.hoogleLocal { packages = with haskellPackages; [ mtl lens ]; }" # $ hoogle server hoogleLocal = { packages ? [] }: self.callPackage ./hoogle.nix { inherit packages; }; diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index 9c1e75232d7..60cce56cca0 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -1,6 +1,7 @@ { stdenv, fetchurl, ghc, pkgconfig, glibcLocales, coreutils, gnugrep, gnused , jailbreak-cabal, hscolour, cpphs, nodejs, lib, removeReferencesTo -}: let isCross = (ghc.cross or null) != null; in +}: +let isCross = (ghc.cross or null) != null; in { pname , dontStrip ? (ghc.isGhcjs or false) @@ -78,6 +79,9 @@ let then "package-db" 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"; newCabalFile = fetchurl { url = newCabalFileUrl; @@ -111,7 +115,7 @@ let defaultConfigureFlags = [ "--verbose" "--prefix=$out" "--libdir=\\$prefix/lib/\\$compiler" "--libsubdir=\\$pkgid" (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. "--package-db=$packageConfDir" (optionalString (enableSharedExecutables && stdenv.isLinux) "--ghc-option=-optl=-Wl,-rpath=$out/lib/${ghc.name}/${pname}-${version}") @@ -331,7 +335,7 @@ stdenv.mkDerivation ({ ''} ${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 done mkdir -p $doc @@ -347,6 +351,14 @@ stdenv.mkDerivation ({ 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 { name = "interactive-${pname}-${version}-environment"; nativeBuildInputs = [ ghcEnv systemBuildInputs ] @@ -356,6 +368,7 @@ stdenv.mkDerivation ({ shellHook = '' export NIX_${ghcCommandCaps}="${ghcEnv}/bin/${ghcCommand}" export NIX_${ghcCommandCaps}PKG="${ghcEnv}/bin/${ghcCommand}-pkg" + # TODO: is this still valid? export NIX_${ghcCommandCaps}_DOCDIR="${ghcEnv}/share/doc/ghc/html" export LD_LIBRARY_PATH="''${LD_LIBRARY_PATH:+''${LD_LIBRARY_PATH}:}${ makeLibraryPath (filter (x: !isNull x) systemBuildInputs) diff --git a/pkgs/development/haskell-modules/hoogle.nix b/pkgs/development/haskell-modules/hoogle.nix index b6063f6ef97..65124d4c700 100644 --- a/pkgs/development/haskell-modules/hoogle.nix +++ b/pkgs/development/haskell-modules/hoogle.nix @@ -52,7 +52,10 @@ let 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 stdenv.mkDerivation { @@ -64,6 +67,10 @@ stdenv.mkDerivation { inherit docPackages; 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 echo importing builtin packages @@ -76,17 +83,13 @@ stdenv.mkDerivation { done echo importing other packages - for i in $docPackages; do - if [[ ! $i == $out ]]; then - for docdir in $i/share/doc/*-${ghcName}-*/* $i/share/doc/*; do - name="$(basename $docdir)" - docdir=$docdir/html - if [[ -d $docdir ]]; then - ln -sfn $docdir $out/share/doc/hoogle/$name - fi - done - fi - done + ${lib.concatMapStringsSep "\n" (el: '' + ln -sfn ${el.haddockDir} "$out/share/doc/hoogle/${el.name}" + '') + (lib.filter (el: el.haddockDir != null) + (builtins.map (p: { haddockDir = p.haddockDir p; + name = p.pname; }) + docPackages))} echo building hoogle database hoogle generate --database $out/share/doc/hoogle/default.hoo --local=$out/share/doc/hoogle diff --git a/pkgs/development/haskell-modules/make-package-set.nix b/pkgs/development/haskell-modules/make-package-set.nix index 87f3a04ebf5..5215fe4a552 100644 --- a/pkgs/development/haskell-modules/make-package-set.nix +++ b/pkgs/development/haskell-modules/make-package-set.nix @@ -25,7 +25,9 @@ }: # return value: a function from self to the package set -self: let +self: + +let inherit (stdenv.lib) fix' extends makeOverridable; inherit (haskellLib) overrideCabal;