@@ -1,4 +1,4 @@
1−{ lib, stdenv, glibcLocales, pkgconfig, ghcForComponent, makeConfigFiles, hsPkgs }:
1+{ lib, stdenv, glibcLocales, pkgconfig, ghcForComponent, makeConfigFiles, hsPkgs, hoogleLocal, haskellLib }:
22
33{ packages, withHoogle ? true, ... } @ args:
44
@@ -23,27 +23,47 @@ let
2323 nativeBuildInputs = lib.concatMap (p: p.components.all.executableToolDepends) selected;
2424
2525 # Set up a "dummy" component to use with ghcForComponent.
26+ component = {
27+ depends = packageInputs;
28+ libs = [];
29+ frameworks = [];
30+ doExactConfig = false;
31+ };
2632 configFiles = makeConfigFiles {
2733 fullName = args.name or name;
2834 identifier.name = name;
29− component = {
30− depends = packageInputs;
31− libs = [];
32− frameworks = [];
33− doExactConfig = false;
34− };
35+ inherit component;
3536 };
3637 ghcEnv = ghcForComponent {
3738 componentName = name;
3839 inherit configFiles;
3940 };
41+
42+ hoogleIndex = let
43+ # Get the doc package for a component, and add attributes that
44+ # hoogle.nix expects.
45+ docPackage = p: lib.getOutput "doc" p // {
46+ pname = p.identifier.name;
47+ haddockDir = lib.const p.haddockDir;
48+ };
49+ in hoogleLocal {
50+ packages = map docPackage (haskellLib.flatLibDepends component);
51+
52+ # Need to add hoogle to hsPkgs.
53+ # inherit (hsPkgs) hoogle;
54+ };
55+
4056 mkDrvArgs = builtins.removeAttrs args ["packages" "withHoogle"];
4157in
4258 stdenv.mkDerivation (mkDrvArgs // {
4359 name = mkDrvArgs.name or name;
4460
45− buildInputs = systemInputs ++ mkDrvArgs.buildInputs or [];
46− nativeBuildInputs = [ ghcEnv ] ++ nativeBuildInputs ++ mkDrvArgs.nativeBuildInputs or [];
61+ buildInputs = systemInputs
62+ ++ mkDrvArgs.buildInputs or []
63+ ++ lib.optional withHoogle hoogleIndex;
64+ nativeBuildInputs = [ ghcEnv ]
65+ ++ nativeBuildInputs
66+ ++ mkDrvArgs.nativeBuildInputs or [];
4767 phases = ["installPhase"];
4868 installPhase = "echo $nativeBuildInputs $buildInputs > $out";
4969 LANG = "en_US.UTF-8";