Skip to content

Commit b90fbaa

Browse files
authored
Add shell.allDeps as a fix for #1793 (#1794)
* Add `shell.allDeps` as a fix for #1793 #1769 added all the tool dependencies of the hsPkgs in a project to the shell. This is great for cabal projects where the set of packages will be limited to those in the plan. It allows these packages to be rebuilt by cabal. For stack projects however this set is much larger (all of stackage), likely to include unwanted tools and tools that may be broken. This change adds `shell.allDeps` and defaults it to `false` for stack projects. Fixes #1793 * Added comments
1 parent fadf922 commit b90fbaa

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

builder/shell-for.nix

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
, withHoogle ? true
1616
, withHaddock ? withHoogle
1717
, exactDeps ? false
18+
, allToolDeps ? !exactDeps
1819
, tools ? {}
1920
, packageSetupDeps ? true
2021
, enableDWARF ? false
@@ -109,8 +110,11 @@ let
109110
nativeBuildInputs = removeSelectedInputs
110111
(uniqueWithName (lib.concatMap (c: c.executableToolDepends)
111112
# When not using `exactDeps` cabal may try to build arbitrary dependencies
112-
# so in this case we need to provide the build tools for all of hsPkgs:
113-
(if exactDeps then selectedComponents else allHsPkgsComponents)));
113+
# so in this case we need to provide the build tools for all of `hsPkgs`.
114+
# In some cases those tools may be unwanted or broken so the `allToolDeps`
115+
# flag can be set to `false` to disable this (stack projects default `allToolDeps`
116+
# to `false` as `hsPkgs` for them includes all of stackage):
117+
(if exactDeps || !allToolDeps then selectedComponents else allHsPkgsComponents)));
114118

115119
# Set up a "dummy" component to use with ghcForComponent.
116120
component = {

modules/shell.nix

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@
2929
type = lib.types.bool;
3030
default = false;
3131
};
32+
allToolDeps = lib.mkOption {
33+
type = lib.types.bool;
34+
default = !config.exactDeps;
35+
description = ''
36+
Indicates if the shell should include all the tool dependencies
37+
of in the haskell packages in the project. Defaulted to `false` in
38+
stack projects (to avoid trying to build the tools used by
39+
every `stackage` package).
40+
'';
41+
};
3242
tools = lib.mkOption {
3343
type = lib.types.attrsOf lib.types.unspecified;
3444
default = {};

modules/stack-project.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,9 @@ with types;
9191
description = "Deprecated in favour of `compiler-nix-name`";
9292
};
9393
};
94+
config = {
95+
# For stack projects we normally do not want to include the tool dependencies
96+
# of all the hsPkgs (all of stackage).
97+
shell.allToolDeps = mkDefault false;
98+
};
9499
}

0 commit comments

Comments
 (0)