on iko/ghcjs-patch-master help sign in
shellFor: Provide correct dependencies
bbd0133Rodney Lorrimar
builder/comp-builder.nix+5−4
@@ -71,9 +71,11 @@ let
71 ++ component.configureFlags
71 ++ component.configureFlags
72 );
72 );
73
73
74+ executableToolDepends =
74− executableToolDepends = lib.concatMap (c: if c.isHaskell or false
75+ (lib.concatMap (c: if c.isHaskell or false
75 then builtins.attrValues (c.components.exes or {})
76 then builtins.attrValues (c.components.exes or {})
76− else [c]) component.build-tools;
77+ else [c]) component.build-tools) ++
78+ lib.optional (component.pkgconfig != []) pkgconfig;
77
79
78 # Unfortunately, we need to wrap ghc commands for cabal builds to
80 # Unfortunately, we need to wrap ghc commands for cabal builds to
79 # work in the nix-shell. See ../doc/removing-with-package-wrapper.md.
81 # work in the nix-shell. See ../doc/removing-with-package-wrapper.md.
@@ -104,7 +106,7 @@ stdenv.mkDerivation ({
104 passthru = {
106 passthru = {
105 inherit (package) identifier;
107 inherit (package) identifier;
106 config = component;
108 config = component;
107− inherit configFiles;
109+ inherit configFiles executableToolDepends;
108 env = shellWrappers;
110 env = shellWrappers;
109
111
110 # The directory containing the haddock documentation.
112 # The directory containing the haddock documentation.
@@ -134,7 +136,6 @@ stdenv.mkDerivation ({
134
136
135 nativeBuildInputs =
137 nativeBuildInputs =
136 [shellWrappers buildPackages.removeReferencesTo]
138 [shellWrappers buildPackages.removeReferencesTo]
137− ++ lib.optional (component.pkgconfig != []) pkgconfig
138 ++ executableToolDepends;
139 ++ executableToolDepends;
139
140
140 SETUP_HS = setup + /bin/Setup;
141 SETUP_HS = setup + /bin/Setup;
builder/shell-for.nix+18−6
@@ -1,17 +1,33 @@
1−{ lib, stdenv, glibcLocales, ghcForComponent, makeConfigFiles, hsPkgs }:
1+{ lib, stdenv, glibcLocales, pkgconfig, ghcForComponent, makeConfigFiles, hsPkgs }:
2
2
3{ packages, withHoogle ? true, ... } @ args:
3{ packages, withHoogle ? true, ... } @ args:
4
4
5let
5let
6 selected = packages hsPkgs;
6 selected = packages hsPkgs;
7+ selectedConfigs = map (p: p.components.all.config) selected;
8+
7 name = if lib.length selected == 1
9 name = if lib.length selected == 1
8 then "ghc-shell-for-${(lib.head selected).name}"
10 then "ghc-shell-for-${(lib.head selected).name}"
9 else "ghc-shell-for-packages";
11 else "ghc-shell-for-packages";
12+
13+ # If `packages = [ a b ]` and `a` depends on `b`, don't build `b`,
14+ # because cabal will end up ignoring that built version, assuming
15+ # new-style commands.
16+ packageInputs = lib.filter
17+ (input: lib.all (cfg: input.identifier != cfg.identifier) selected)
18+ (lib.concatMap (cfg: cfg.depends) selectedConfigs);
19+
20+ # Add the system libraries and build tools of the selected haskell
21+ # packages to the shell.
22+ systemInputs = lib.concatMap (p: p.components.all.buildInputs) selected;
23+ nativeBuildInputs = lib.concatMap (p: p.components.all.executableToolDepends) selected;
24+
25+ # Set up a "dummy" component to use with ghcForComponent.
10 configFiles = makeConfigFiles {
26 configFiles = makeConfigFiles {
11 fullName = args.name or name;
27 fullName = args.name or name;
12 identifier.name = name;
28 identifier.name = name;
13 component = {
29 component = {
14− depends = selected;
30+ depends = packageInputs;
15 libs = [];
31 libs = [];
16 frameworks = [];
32 frameworks = [];
17 doExactConfig = false;
33 doExactConfig = false;
@@ -22,10 +38,6 @@ let
22 inherit configFiles;
38 inherit configFiles;
23 };
39 };
24 mkDrvArgs = builtins.removeAttrs args ["packages" "withHoogle"];
40 mkDrvArgs = builtins.removeAttrs args ["packages" "withHoogle"];
25−
26− # fixme: check if systemInputs and nativeBuildInputs are necessary
27− systemInputs = [];
28− nativeBuildInputs = [];
29in
41in
30 stdenv.mkDerivation (mkDrvArgs // {
42 stdenv.mkDerivation (mkDrvArgs // {
31 name = mkDrvArgs.name or name;
43 name = mkDrvArgs.name or name;