Skip to content

Commit 9b09702

Browse files
committed
Add shell.allDeps as a fix
#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
1 parent 506208f commit 9b09702

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

builder/shell-for.nix

Lines changed: 2 additions & 1 deletion
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
@@ -110,7 +111,7 @@ let
110111
(uniqueWithName (lib.concatMap (c: c.executableToolDepends)
111112
# When not using `exactDeps` cabal may try to build arbitrary dependencies
112113
# so in this case we need to provide the build tools for all of hsPkgs:
113-
(if exactDeps then selectedComponents else allHsPkgsComponents)));
114+
(if exactDeps || !allToolDeps then selectedComponents else allHsPkgsComponents)));
114115

115116
# Set up a "dummy" component to use with ghcForComponent.
116117
component = {

modules/shell.nix

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@
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.
39+
'';
40+
};
3241
tools = lib.mkOption {
3342
type = lib.types.attrsOf lib.types.unspecified;
3443
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)