Skip to content

Commit b6ac860

Browse files
committed
wip: shellFor depends of depends
1 parent b71e3f4 commit b6ac860

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

builder/shell-for.nix

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

55
let
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+
# 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+
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 = [];
2941
in
3042
stdenv.mkDerivation (mkDrvArgs // {
3143
name = mkDrvArgs.name or name;

0 commit comments

Comments
 (0)