on iko/ghcjs-patch-master help sign in
shellFor: Add the hoogle index
c69cf9eRodney Lorrimar
builder/default.nix+8−1
@@ -20,6 +20,13 @@ let
20 inherit ghc haskellLib nonReinstallablePkgs;
20 inherit ghc haskellLib nonReinstallablePkgs;
21 };
21 };
22
22
23+ hoogleLocal = let
24+ nixpkgsHoogleLocal = import (pkgs.path + /pkgs/development/haskell-modules/hoogle.nix);
25+ in { packages ? [], hoogle ? pkgs.haskellPackages.hoogle }:
26+ haskellLib.weakCallPackage pkgs nixpkgsHoogleLocal {
27+ inherit packages hoogle;
28+ };
29+
23in {
30in {
24 # Build a Haskell package from its config.
31 # Build a Haskell package from its config.
25 # TODO: this pkgs is the adjusted pkgs, but pkgs.pkgs is unadjusted
32 # TODO: this pkgs is the adjusted pkgs, but pkgs.pkgs is unadjusted
@@ -29,7 +36,7 @@ in {
29
36
30 # Same as haskellPackages.shellFor in nixpkgs.
37 # Same as haskellPackages.shellFor in nixpkgs.
31 shellFor = haskellLib.weakCallPackage pkgs ./shell-for.nix {
38 shellFor = haskellLib.weakCallPackage pkgs ./shell-for.nix {
32− inherit hsPkgs ghcForComponent makeConfigFiles;
39+ inherit hsPkgs ghcForComponent makeConfigFiles hoogleLocal haskellLib;
33 inherit (buildPackages) glibcLocales;
40 inherit (buildPackages) glibcLocales;
34 };
41 };
35}
42}
builder/shell-for.nix+29−9
@@ -1,4 +1,4 @@
1−{ lib, stdenv, glibcLocales, pkgconfig, ghcForComponent, makeConfigFiles, hsPkgs }:
1+{ lib, stdenv, glibcLocales, pkgconfig, ghcForComponent, makeConfigFiles, hsPkgs, hoogleLocal, haskellLib }:
2
2
3{ packages, withHoogle ? true, ... } @ args:
3{ packages, withHoogle ? true, ... } @ args:
4
4
@@ -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;
24
24
25 # Set up a "dummy" component to use with ghcForComponent.
25 # Set up a "dummy" component to use with ghcForComponent.
26+ component = {
27+ depends = packageInputs;
28+ libs = [];
29+ frameworks = [];
30+ doExactConfig = false;
31+ };
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;
31− libs = [];
32− frameworks = [];
33− doExactConfig = false;
34− };
35 };
36 };
36 ghcEnv = ghcForComponent {
37 ghcEnv = ghcForComponent {
37 componentName = name;
38 componentName = name;
38 inherit configFiles;
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 mkDrvArgs = builtins.removeAttrs args ["packages" "withHoogle"];
56 mkDrvArgs = builtins.removeAttrs args ["packages" "withHoogle"];
41in
57in
42 stdenv.mkDerivation (mkDrvArgs // {
58 stdenv.mkDerivation (mkDrvArgs // {
43 name = mkDrvArgs.name or name;
59 name = mkDrvArgs.name or name;
44
60
45− buildInputs = systemInputs ++ mkDrvArgs.buildInputs or [];
61+ buildInputs = systemInputs
62+ ++ mkDrvArgs.buildInputs or []
63+ ++ lib.optional withHoogle hoogleIndex;
64+ nativeBuildInputs = [ ghcEnv ]
65+ ++ nativeBuildInputs
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";