@@ -1,4 +1,4 @@
1−{ lib, stdenv, glibcLocales, pkgconfig, ghcForComponent, makeConfigFiles, hsPkgs }:
1+{ lib, stdenv, glibcLocales, pkgconfig, ghcForComponent, makeConfigFiles, hsPkgs, hoogleLocal, haskellLib }:
3{ packages, withHoogle ? true, ... } @ args:
3{ packages, withHoogle ? true, ... } @ args:
@@ -23,27 +23,47 @@ let
23 nativeBuildInputs = lib.concatMap (p: p.components.all.executableToolDepends) selected;
23 nativeBuildInputs = lib.concatMap (p: p.components.all.executableToolDepends) selected;
25 # Set up a "dummy" component to use with ghcForComponent.
25 # Set up a "dummy" component to use with ghcForComponent.
27+ depends = packageInputs;
30+ doExactConfig = false;
26 configFiles = makeConfigFiles {
32 configFiles = makeConfigFiles {
27 fullName = args.name or name;
33 fullName = args.name or name;
28 identifier.name = name;
34 identifier.name = name;
29− component = {
35+ inherit component;
30− depends = packageInputs;
33− doExactConfig = false;
36 ghcEnv = ghcForComponent {
37 ghcEnv = ghcForComponent {
37 componentName = name;
38 componentName = name;
38 inherit configFiles;
39 inherit configFiles;
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;
50+ packages = map docPackage (haskellLib.flatLibDepends component);
52+ # Need to add hoogle to hsPkgs.
53+ # inherit (hsPkgs) hoogle;
40 mkDrvArgs = builtins.removeAttrs args ["packages" "withHoogle"];
56 mkDrvArgs = builtins.removeAttrs args ["packages" "withHoogle"];
42 stdenv.mkDerivation (mkDrvArgs // {
58 stdenv.mkDerivation (mkDrvArgs // {
43 name = mkDrvArgs.name or name;
59 name = mkDrvArgs.name or name;
45− buildInputs = systemInputs ++ mkDrvArgs.buildInputs or [];
61+ buildInputs = systemInputs
62+ ++ mkDrvArgs.buildInputs or []
63+ ++ lib.optional withHoogle hoogleIndex;
64+ nativeBuildInputs = [ ghcEnv ]
46− nativeBuildInputs = [ ghcEnv ] ++ nativeBuildInputs ++ mkDrvArgs.nativeBuildInputs or [];
66+ ++ mkDrvArgs.nativeBuildInputs or [];
47 phases = ["installPhase"];
67 phases = ["installPhase"];
48 installPhase = "echo $nativeBuildInputs $buildInputs > $out";
68 installPhase = "echo $nativeBuildInputs $buildInputs > $out";
49 LANG = "en_US.UTF-8";
69 LANG = "en_US.UTF-8";