on iko/ghcjs-patch-master help sign in
shellFor: Provide correct dependencies

Now the shell provides the dependencies of the given Haskell packages, and not the packages themselves. System libraries and Haskell executables are added to the shell.

commit90cdb9701d53e2596ff963daa169cd14e68e3a22 authorRodney Lorrimar <rodney.lorrimar@iohk.io> dateMon 20 May 2019, 19:33 (7 years ago) parentb3b4133
2 files changed+23−10
builder/comp-builder.nix+5−4 builder/shell-for.nix+18−6
builder/comp-builder.nix+5−4
@@ -71,9 +71,11 @@ let
7171 ++ component.configureFlags
7272 );
7373
74− executableToolDepends = lib.concatMap (c: if c.isHaskell or false
74+ executableToolDepends =
75+ (lib.concatMap (c: if c.isHaskell or false
7576 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;
7779
7880 # Unfortunately, we need to wrap ghc commands for cabal builds to
7981 # work in the nix-shell. See ../doc/removing-with-package-wrapper.md.
@@ -104,7 +106,7 @@ stdenv.mkDerivation ({
104106 passthru = {
105107 inherit (package) identifier;
106108 config = component;
107− inherit configFiles;
109+ inherit configFiles executableToolDepends;
108110 env = shellWrappers;
109111
110112 # The directory containing the haddock documentation.
@@ -134,7 +136,6 @@ stdenv.mkDerivation ({
134136
135137 nativeBuildInputs =
136138 [shellWrappers buildPackages.removeReferencesTo]
137− ++ lib.optional (component.pkgconfig != []) pkgconfig
138139 ++ executableToolDepends;
139140
140141 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 }:
22
33{ packages, withHoogle ? true, ... } @ args:
44
55let
66 selected = packages hsPkgs;
7+ selectedConfigs = map (p: p.components.all.config) selected;
8+
79 name = if lib.length selected == 1
810 then "ghc-shell-for-${(lib.head selected).name}"
911 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.
1026 configFiles = makeConfigFiles {
1127 fullName = args.name or name;
1228 identifier.name = name;
1329 component = {
14− depends = selected;
30+ depends = packageInputs;
1531 libs = [];
1632 frameworks = [];
1733 doExactConfig = false;
@@ -22,10 +38,6 @@ let
2238 inherit configFiles;
2339 };
2440 mkDrvArgs = builtins.removeAttrs args ["packages" "withHoogle"];
25−
26− # fixme: check if systemInputs and nativeBuildInputs are necessary
27− systemInputs = [];
28− nativeBuildInputs = [];
2941in
3042 stdenv.mkDerivation (mkDrvArgs // {
3143 name = mkDrvArgs.name or name;