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