on iko/ghcjs-patch-master help sign in
Merge PR #147
2a88f7dRodney 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/make-config-files.nix+1−10
@@ -6,15 +6,6 @@ let
6 echo "${field}: ${lib.concatStringsSep " " xs}" >> $out/cabal.config
6 echo "${field}: ${lib.concatStringsSep " " xs}" >> $out/cabal.config
7 '';
7 '';
8
8
9− flatDepends = component:
10− let
11− makePairs = map (p: rec { key="${val}"; val=(p.components.library or p); });
12− closure = builtins.genericClosure {
13− startSet = makePairs component.depends;
14− operator = {val,...}: makePairs val.config.depends;
15− };
16− in map ({val,...}: val) closure;
17−
18 exactDep = pdbArg: p: ''
9 exactDep = pdbArg: p: ''
19 if id=$(target-pkg ${pdbArg} field ${p} id --simple-output); then
10 if id=$(target-pkg ${pdbArg} field ${p} id --simple-output); then
20 echo "--dependency=${p}=$id" >> $out/configure-flags
11 echo "--dependency=${p}=$id" >> $out/configure-flags
@@ -58,7 +49,7 @@ in { identifier, component, fullName, flags ? {} }:
58
49
59 ${lib.concatMapStringsSep "\n" (p: ''
50 ${lib.concatMapStringsSep "\n" (p: ''
60 target-pkg --package-db ${p}/package.conf.d dump | target-pkg --force --package-db $out/package.conf.d register -
51 target-pkg --package-db ${p}/package.conf.d dump | target-pkg --force --package-db $out/package.conf.d register -
61− '') (flatDepends component)}
52+ '') (haskellLib.flatLibDepends component)}
62
53
63 # Note: we pass `clear` first to ensure that we never consult the implicit global package db.
54 # Note: we pass `clear` first to ensure that we never consult the implicit global package db.
64 ${flagsAndConfig "package-db" ["clear" "$out/package.conf.d"]}
55 ${flagsAndConfig "package-db" ["clear" "$out/package.conf.d"]}
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";
lib/default.nix+12
@@ -80,4 +80,16 @@ with haskellLib;
80 let f' = if lib.isFunction f then f else import f;
80 let f' = if lib.isFunction f then f else import f;
81 args' = (builtins.intersectAttrs (builtins.functionArgs f') scope) // args;
81 args' = (builtins.intersectAttrs (builtins.functionArgs f') scope) // args;
82 in f' args';
82 in f' args';
83+
84+ # Collect all (transitive) Haskell library dependencies of a
85+ # component.
86+ ## flatLibDepends :: Component -> [Package]
87+ flatLibDepends = component:
88+ let
89+ makePairs = map (p: rec { key="${val}"; val=(p.components.library or p); });
90+ closure = builtins.genericClosure {
91+ startSet = makePairs component.depends;
92+ operator = {val,...}: makePairs val.config.depends;
93+ };
94+ in map ({val,...}: val) closure;
83}
95}
test/tests.sh+7
@@ -61,4 +61,11 @@ nix-shell $NIX_BUILD_ARGS \
61 --run 'cd shell-for && cabal new-build all'
61 --run 'cd shell-for && cabal new-build all'
62echo >& 2
62echo >& 2
63
63
64+printf "*** Checking shellFor has a working hoogle index...\n" >& 2
65+nix-shell $NIX_BUILD_ARGS \
66+ --pure ./default.nix \
67+ -A shell-for.env \
68+ --run 'hoogle ConduitT | grep Data.Conduit'
69+echo >& 2
70+
64printf "\n*** Finished successfully\n" >& 2
71printf "\n*** Finished successfully\n" >& 2