Skip to content

Commit beaf110

Browse files
committed
Fix shellFor components argument
1 parent 44ecbc8 commit beaf110

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

builder/comp-builder.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ let
318318
++ builtins.concatLists pkgconfig;
319319

320320
buildInputs = component.libs
321-
++ map (d: d.components.library or d) component.depends;
321+
++ map haskellLib.dependToLib component.depends;
322322

323323
nativeBuildInputs =
324324
[shellWrappers buildPackages.removeReferencesTo]

builder/shell-for.nix

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# in the selected packages. If only as subset of the components will be
1010
# worked on in the shell then we can pass a different `components` function
1111
# to select those.
12-
, components ? ps: lib.concatMap haskellLib.getAllComponents (packages hsPkgs)
12+
, components ? ps: lib.concatMap haskellLib.getAllComponents (packages ps)
1313
# Additional packages to be added unconditionally
1414
, additional ? _: []
1515
, withHoogle ? true
@@ -50,26 +50,20 @@ let
5050
# We have to do this slightly differently because we will be looking at the actual components rather
5151
# than the packages.
5252

53-
# Given a list of packages, removes those which were selected as part of the shell.
54-
# We do this on the basis of their identifiers being the same, not direct equality (why?).
55-
removeSelectedPackages =
56-
# All the identifiers of the selected packages
57-
let selectedPackageIds = map (p: p.identifier) selectedPackages;
58-
in lib.filter (input: !(builtins.elem (input.identifier or null) selectedPackageIds));
59-
60-
# Given a list of derivations, removes those which are components of packages which were selected as part of the shell.
53+
# Given a list of `depends`, removes those which are components of packages which were selected as part of the shell.
6154
removeSelectedInputs =
6255
# All the components of the selected packages: we shouldn't add any of these as dependencies
63-
let selectedPackageComponents = map (x: x.name) (lib.concatMap haskellLib.getAllComponents selectedPackages);
64-
in lib.filter (input: !(builtins.elem input.name selectedPackageComponents));
56+
let selectedPackageComponents = map (x: x.name) selectedComponents;
57+
in lib.filter (input:
58+
!(builtins.elem ((haskellLib.dependToLib input).name or null) selectedPackageComponents));
6559

6660
# We need to remove any dependencies which are selected packages (see above).
67-
# `depends` contains packages so we use 'removeSelectedPackages`.
68-
packageInputs = removeSelectedPackages (lib.concatMap (cfg: cfg.depends) selectedConfigs) ++ additionalPackages;
61+
packageInputs = removeSelectedInputs (lib.concatMap (cfg: cfg.depends) selectedConfigs)
62+
++ additionalPackages;
6963

7064
# Add the system libraries and build tools of the selected haskell packages to the shell.
7165
# We need to remove any inputs which are selected components (see above).
72-
# `buildInputs`, `propagatedBuildInputs`, and `executableToolDepends` contain component
66+
# `buildInputs`, `propagatedBuildInputs`, and `executableToolDepends` contain component
7367
# derivations, not packages, so we use `removeSelectedInputs`).
7468
systemInputs = removeSelectedInputs (lib.concatMap
7569
(c: c.buildInputs ++ c.propagatedBuildInputs) selectedComponents);
@@ -115,7 +109,7 @@ let
115109
}
116110
));
117111

118-
mkDrvArgs = builtins.removeAttrs args ["packages" "additional" "withHoogle" "tools"];
112+
mkDrvArgs = builtins.removeAttrs args ["packages" "components" "additional" "withHoogle" "tools"];
119113
in
120114
mkShell (mkDrvArgs // {
121115
name = mkDrvArgs.name or name;

lib/default.nix

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,4 +333,8 @@ in {
333333
}
334334
else src.origSrc or src; # If there is a subDir and origSrc (but no filter) use origSrc
335335
};
336+
337+
# Converts from a `compoent.depends` value to a library derivation.
338+
# In the case of sublibs the `depends` value should already be the derivation.
339+
dependToLib = d: d.components.library or d;
336340
}

0 commit comments

Comments
 (0)