From 4e6c41e7fa8b415951208d7dd7e99211316f59ec Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Sun, 6 Aug 2017 21:46:22 +0200 Subject: [PATCH 1/4] pkgs/haskell-modules: fix hoogleLocal docstring --- pkgs/development/haskell-modules/configuration-common.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/haskell-modules/configuration-common.nix b/pkgs/development/haskell-modules/configuration-common.nix index 0d2f235862f..15c06bcfd93 100644 --- a/pkgs/development/haskell-modules/configuration-common.nix +++ b/pkgs/development/haskell-modules/configuration-common.nix @@ -34,7 +34,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; }; From 3f27a3691224fe0485ca1dda39fa7789b4a3892d Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Sun, 6 Aug 2017 21:46:49 +0200 Subject: [PATCH 2/4] pkgs/haskell-modules: two small vanity fixes --- pkgs/development/haskell-modules/generic-builder.nix | 3 ++- pkgs/development/haskell-modules/make-package-set.nix | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index 7e99300a41e..de90184ac09 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) 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; From e9e25ec5fe773ef6bae9363e8f87fd0909f3ee56 Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Sun, 6 Aug 2017 21:48:22 +0200 Subject: [PATCH 3/4] pkgs/haskell-modules: expose haddockDir as passthru variable WIP If the `hoogle.nix` file wants to have any sane chance of finding haddock outputs, the packages need to export the haddock folders as an identifier. A few TODOs still stand, like passing self to the package instead of needing to pass it to `haddockDir`. Maybe the exported identifier should be integrated into the fixpoint somehow instead of using `passthru`? --- .../haskell-modules/generic-builder.nix | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index de90184ac09..e12babbd414 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -79,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; @@ -112,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}") @@ -332,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 @@ -348,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 ] @@ -357,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) From 4a8efae000a0a9f8e61abfc76189259077b4a3ea Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Sun, 6 Aug 2017 22:02:50 +0200 Subject: [PATCH 4/4] pkgs/haskell-modules/hoogle.nix: find haddocks by `haddockDir` Previously a few clumsy shell globs were used to find haddock output, which broke every time something in `generic-builder.nix` changed. Use the new `haddockDir` identifier exported by haskell packages. --- pkgs/development/haskell-modules/hoogle.nix | 27 ++++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) 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