on iko/ghcjs-patch-master help sign in
Fix shellFor components argument (#1079)
commit618ff607d3aa0e7396393aca4180f1d31a920ecb authorHamish Mackenzie <Hamish.Mackenzie@iohk.io> dateThu 8 Apr 2021, 15:33 (6 years ago) parent94a3995
3 files changed+14−16
builder/comp-builder.nix+1−1 builder/shell-for.nix+9−15 lib/default.nix+4
builder/comp-builder.nix+1−1
@@ -337,7 +337,7 @@ let
337337 ++ builtins.concatLists pkgconfig;
338338
339339 buildInputs = component.libs
340− ++ map (d: d.components.library or d) component.depends;
340+ ++ map haskellLib.dependToLib component.depends;
341341
342342 nativeBuildInputs =
343343 [shellWrappers buildPackages.removeReferencesTo]
builder/shell-for.nix+9−15
@@ -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"];
119113in
120114 mkShell (mkDrvArgs // {
121115 name = mkDrvArgs.name or name;
lib/default.nix+4
@@ -350,4 +350,8 @@ in {
350350 })
351351 ];
352352 }).config;
353+
354+ # Converts from a `compoent.depends` value to a library derivation.
355+ # In the case of sublibs the `depends` value should already be the derivation.
356+ dependToLib = d: d.components.library or d;
353357}