git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #5908 from cstrahan/hoogle-local-ng

haskell-ng: hoogleLocal support I believe this code ought to be used as follows: { packageOverrides = pkgs : let self = pkgs.pkgs; in rec { hsEnv = pkgs.haskell-ng.packages.ghc784.ghcWithPackages (p: with p; (haskellDev p) ++(myPackages p) # add more packages here ); hsEnvHoogle = withHoogle hsEnv; withHoogle = haskellEnv: with pkgs.haskellngPackages; import <nixpkgs/pkgs/development/libraries/haskell/hoogle/local.nix> { stdenv = pkgs.stdenv; inherit hoogle rehoo ghc; packages = haskellEnv.paths; }; }; }

commit75f82f50e6a43d871fd7442d3b2dc943d0eb0bb0 authorPeter Simons <simons@cryp.to> dateWed 17 Jun 2015, 15:07 (11 years ago) parent101cdcc3859f7b
5 files changed+126−3
pkgs/development/haskell-modules/default.nix+1 pkgs/development/haskell-modules/hoogle-local-wrapper.sh+6 pkgs/development/haskell-modules/hoogle.nix+107 pkgs/development/haskell-modules/lib.nix+6 pkgs/development/haskell-modules/with-packages-wrapper.nix+6−3
pkgs/development/haskell-modules/default.nix+1
@@ -56,6 +56,7 @@ let
5656
5757 ghcWithPackages = pkgs: callPackage ./with-packages-wrapper.nix {
5858 inherit (self) llvmPackages;
59+ haskellPackages = self;
5960 packages = pkgs self;
6061 };
6162
pkgs/development/haskell-modules/hoogle-local-wrapper.shnew file+6
@@ -0,0 +1,6 @@
1+#! @shell@
2+
3+COMMAND=$1
4+shift
5+HOOGLE_DOC_PATH=@out@/share/hoogle/doc exec @hoogle@/bin/hoogle \
6+ "$COMMAND" -d @out@/share/hoogle "$@"
pkgs/development/haskell-modules/hoogle.nixnew file+107
@@ -0,0 +1,107 @@
1+# Install not only the Hoogle library and executable, but also a local Hoogle
2+# database which provides "Source" links to all specified 'packages' -- or the
3+# current Haskell Platform if no custom package set is provided.
4+#
5+# It is intended to be used in config.nix similarly to:
6+#
7+# { packageOverrides = pkgs: rec {
8+#
9+# haskellPackages =
10+# let callPackage = pkgs.lib.callPackageWith haskellPackages;
11+# in pkgs.recurseIntoAttrs (pkgs.haskellPackages.override {
12+# extension = self: super: {
13+# hoogleLocal = pkgs.haskellPackages.hoogleLocal.override {
14+# packages = with pkgs.haskellPackages; [
15+# mmorph
16+# monadControl
17+# ];
18+# };
19+# };
20+# });
21+# }}
22+#
23+# This will build mmorph and monadControl, and have the hoogle installation
24+# refer to their documentation via symlink so they are not garbage collected.
25+
26+{ stdenv, hoogle, rehoo
27+, ghc, packages ? [ ghc.ghc ]
28+}:
29+
30+let
31+ inherit (stdenv.lib) optional;
32+ wrapper = ./hoogle-local-wrapper.sh;
33+in
34+stdenv.mkDerivation {
35+ name = "hoogle-local-0.1";
36+ buildInputs = [hoogle rehoo];
37+
38+ phases = [ "installPhase" ];
39+
40+ docPackages = packages;
41+ installPhase = ''
42+ if [ -z "$docPackages" ]; then
43+ echo "ERROR: The packages attribute has not been set"
44+ exit 1
45+ fi
46+
47+ mkdir -p $out/share/hoogle/doc
48+ export HOOGLE_DOC_PATH=$out/share/hoogle/doc
49+
50+ cd $out/share/hoogle
51+
52+ function import_dbs() {
53+ find $1 -name '*.txt' | while read f; do
54+ newname=$(basename "$f" | tr '[:upper:]' '[:lower:]')
55+ if [[ -f $f && ! -f ./$newname ]]; then
56+ cp -p $f ./$newname
57+ hoogle convert -d "$(dirname $f)" "./$newname"
58+ fi
59+ done
60+ }
61+
62+ for i in $docPackages; do
63+ findInputs $i docPackages propagated-native-build-inputs
64+ findInputs $i docPackages propagated-build-inputs
65+ done
66+
67+ for i in $docPackages; do
68+ if [[ ! $i == $out ]]; then
69+ for docdir in $i/share/doc/*-ghc-*/* $i/share/doc/*; do
70+ if [[ -d $docdir ]]; then
71+ import_dbs $docdir
72+ ln -sf $docdir $out/share/hoogle/doc
73+ fi
74+ done
75+ fi
76+ done
77+
78+ import_dbs ${ghc}/share/doc/ghc*/html/libraries
79+ ln -sf ${ghc}/share/doc/ghc*/html/libraries/* $out/share/hoogle/doc
80+
81+ chmod 644 *.hoo *.txt
82+ rehoo -j4 -c64 .
83+
84+ rm -fr downloads *.dep *.txt
85+ mv default.hoo x || exit 0
86+ rm -f *.hoo
87+ mv x default.hoo || exit 1
88+
89+ if [ ! -f default.hoo ]; then
90+ echo "Unable to build the default Hoogle database"
91+ exit 1
92+ fi
93+
94+ mkdir -p $out/bin
95+ substitute ${wrapper} $out/bin/hoogle \
96+ --subst-var out --subst-var-by shell ${stdenv.shell} \
97+ --subst-var-by hoogle ${hoogle}
98+ chmod +x $out/bin/hoogle
99+ '';
100+
101+ meta = {
102+ description = "A local Hoogle database";
103+ platforms = ghc.meta.platforms;
104+ hydraPlatforms = with stdenv.lib.platforms; none;
105+ maintainers = with stdenv.lib.maintainers; [ ttuegel ];
106+ };
107+}
pkgs/development/haskell-modules/lib.nix+6
@@ -79,4 +79,10 @@ rec {
7979
8080 triggerRebuild = drv: i: overrideCabal drv (drv: { postUnpack = ": trigger rebuild ${toString i}"; });
8181
82+ withHoogle = haskellEnv: with haskellEnv.haskellPackages;
83+ import ./hoogle.nix {
84+ inherit (pkgs) stdenv;
85+ inherit hoogle rehoo ghc;
86+ packages = haskellEnv.paths;
87+ };
8288}
pkgs/development/haskell-modules/with-packages-wrapper.nix+6−3
@@ -1,6 +1,7 @@
11{ stdenv, lib, ghc, llvmPackages, packages, buildEnv, makeWrapper
22, ignoreCollisions ? false, withLLVM ? false
33, postBuild ? ""
4+, haskellPackages
45}:
56
67# This wrapper works only with GHC 6.12 or later.
@@ -94,7 +95,9 @@ buildEnv {
9495 ${lib.optionalString hasLibraries "$out/bin/${ghcCommand}-pkg recache"}
9596 $out/bin/${ghcCommand}-pkg check
9697 '' + postBuild;
97−} // {
98− preferLocalBuild = true;
99− inherit (ghc) version meta;
98+ passthru = {
99+ preferLocalBuild = true;
100+ inherit (ghc) version meta;
101+ inherit haskellPackages;
102+ };
100103}