on iko/ghcjs-patch-master help sign in
shellFor: Add the hoogle index
commitc69cf9ed600490d4189e5013af0410f97ba12587 authorRodney Lorrimar <rodney.lorrimar@iohk.io> dateSun 26 May 2019, 16:39 (7 years ago) parenta4479de
2 files changed+37−10
builder/default.nix+8−1 builder/shell-for.nix+29−9
builder/default.nix+8−1
@@ -20,6 +20,13 @@ let
2020 inherit ghc haskellLib nonReinstallablePkgs;
2121 };
2222
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+
2330in {
2431 # Build a Haskell package from its config.
2532 # TODO: this pkgs is the adjusted pkgs, but pkgs.pkgs is unadjusted
@@ -29,7 +36,7 @@ in {
2936
3037 # Same as haskellPackages.shellFor in nixpkgs.
3138 shellFor = haskellLib.weakCallPackage pkgs ./shell-for.nix {
32− inherit hsPkgs ghcForComponent makeConfigFiles;
39+ inherit hsPkgs ghcForComponent makeConfigFiles hoogleLocal haskellLib;
3340 inherit (buildPackages) glibcLocales;
3441 };
3542}
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 }:
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";