|
1 |
| -{ lib, stdenv, glibcLocales, pkgconfig, ghcForComponent, makeConfigFiles, hsPkgs }: |
| 1 | +{ lib, stdenv, glibcLocales, pkgconfig, ghcForComponent, makeConfigFiles, hsPkgs, hoogleLocal, haskellLib }: |
2 | 2 |
|
3 | 3 | { packages, withHoogle ? true, ... } @ args:
|
4 | 4 |
|
|
23 | 23 | nativeBuildInputs = lib.concatMap (p: p.components.all.executableToolDepends) selected;
|
24 | 24 |
|
25 | 25 | # Set up a "dummy" component to use with ghcForComponent.
|
| 26 | + component = { |
| 27 | + depends = packageInputs; |
| 28 | + libs = []; |
| 29 | + frameworks = []; |
| 30 | + doExactConfig = false; |
| 31 | + }; |
26 | 32 | configFiles = makeConfigFiles {
|
27 | 33 | fullName = args.name or name;
|
28 | 34 | identifier.name = name;
|
29 |
| - component = { |
30 |
| - depends = packageInputs; |
31 |
| - libs = []; |
32 |
| - frameworks = []; |
33 |
| - doExactConfig = false; |
34 |
| - }; |
| 35 | + inherit component; |
35 | 36 | };
|
36 | 37 | ghcEnv = ghcForComponent {
|
37 | 38 | componentName = name;
|
38 | 39 | inherit configFiles;
|
39 | 40 | };
|
| 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 | + |
40 | 56 | mkDrvArgs = builtins.removeAttrs args ["packages" "withHoogle"];
|
41 | 57 | in
|
42 | 58 | stdenv.mkDerivation (mkDrvArgs // {
|
43 | 59 | name = mkDrvArgs.name or name;
|
44 | 60 |
|
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 []; |
47 | 67 | phases = ["installPhase"];
|
48 | 68 | installPhase = "echo $nativeBuildInputs $buildInputs > $out";
|
49 | 69 | LANG = "en_US.UTF-8";
|
|
0 commit comments