Skip to content

shellFor: provide build tools for all packages when exactDeps = false. Fix #1753. #1769

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions builder/comp-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,12 @@ let
executableToolDepends =
(lib.concatMap (c: if c.isHaskell or false
then builtins.attrValues (c.components.exes or {})
else [c])
(builtins.filter (x: !(isNull x))
(map
else [c])
(builtins.filter (x: !(isNull x)
# We always exclude hsc2hs from build-tools because it is unecessary as it is provided by ghc
# and hsc2hs from ghc is first in PATH so the one from build-tools is never used.
&& x.identifier.name or "" != "hsc2hs")
(map
(p: if builtins.isFunction p
then p { inherit (package.identifier) version; inherit revision; }
else p) build-tools))) ++
Expand Down Expand Up @@ -328,7 +331,7 @@ let
outputHashMode = "recursive";
outputHashAlgo = "sha256";
};

drv = stdenv.mkDerivation (commonAttrs // contentAddressedAttrs // {
pname = nameOnly;
inherit (package.identifier) version;
Expand Down
7 changes: 6 additions & 1 deletion builder/shell-for.nix
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ let
selectedComponents =
lib.filter isSelectedComponent (lib.attrValues transitiveDependenciesComponents);

allHsPkgsComponents = lib.concatMap haskellLib.getAllComponents (builtins.attrValues hsPkgs);

# Given a list of `depends`, removes those which are selected components
removeSelectedInputs =
lib.filter (input: !(isSelectedComponent input));
Expand Down Expand Up @@ -105,7 +107,10 @@ let
systemInputs = removeSelectedInputs (uniqueWithName allSystemInputs);

nativeBuildInputs = removeSelectedInputs
(lib.concatMap (c: c.executableToolDepends) selectedComponents);
(uniqueWithName (lib.concatMap (c: c.executableToolDepends)
# When not using `exactDeps` cabal may try to build arbitrary dependencies
# so in this case we need to provide the build tools for all of hsPkgs:
(if exactDeps then selectedComponents else allHsPkgsComponents)));

# Set up a "dummy" component to use with ghcForComponent.
component = {
Expand Down