|
1 |
| -{ lib, stdenv, glibcLocales, ghcForComponent, makeConfigFiles, hsPkgs }: |
| 1 | +{ lib, stdenv, glibcLocales, pkgconfig, ghcForComponent, makeConfigFiles, hsPkgs }: |
2 | 2 |
|
3 | 3 | { packages, withHoogle ? true, ... } @ args:
|
4 | 4 |
|
5 | 5 | let
|
6 | 6 | selected = packages hsPkgs;
|
| 7 | + selectedConfigs = map (p: p.components.all.config) selected; |
| 8 | + |
7 | 9 | name = if lib.length selected == 1
|
8 | 10 | then "ghc-shell-for-${(lib.head selected).name}"
|
9 | 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 | + # fixme: messy duplication from comp-builder.nix |
| 21 | + nativeBuildInputs = lib.concatMap (cfg: (lib.concatMap (c: if c.isHaskell or false |
| 22 | + then builtins.attrValues (c.components.exes or {}) |
| 23 | + else [c]) cfg.build-tools) ++ lib.optional (cfg.pkgconfig != []) pkgconfig) selectedConfigs; |
| 24 | + systemInputs = lib.concatMap (cfg: cfg.libs ++ cfg.frameworks ++ lib.concatLists cfg.pkgconfig) selectedConfigs; |
| 25 | + |
10 | 26 | configFiles = makeConfigFiles {
|
11 | 27 | fullName = args.name or name;
|
12 | 28 | identifier.name = name;
|
13 | 29 | component = {
|
14 |
| - depends = selected; |
| 30 | + depends = packageInputs; |
15 | 31 | libs = [];
|
16 | 32 | frameworks = [];
|
17 | 33 | doExactConfig = false;
|
|
22 | 38 | inherit configFiles;
|
23 | 39 | };
|
24 | 40 | mkDrvArgs = builtins.removeAttrs args ["packages" "withHoogle"];
|
25 |
| - |
26 |
| - # fixme: check if systemInputs and nativeBuildInputs are necessary |
27 |
| - systemInputs = []; |
28 |
| - nativeBuildInputs = []; |
29 | 41 | in
|
30 | 42 | stdenv.mkDerivation (mkDrvArgs // {
|
31 | 43 | name = mkDrvArgs.name or name;
|
|
0 commit comments