Skip to content

Commit da5e52c

Browse files
authored
Include all pre-existing ghc pkgs in shell, unless exactDeps (#2375)
Fixes #2168
1 parent 794d2e7 commit da5e52c

File tree

4 files changed

+61
-55
lines changed

4 files changed

+61
-55
lines changed

builder/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ let
7979

8080
# Same as haskellPackages.shellFor in nixpkgs.
8181
shellFor = haskellLib.weakCallPackage pkgs ./shell-for.nix {
82-
inherit hsPkgs ghcForComponent makeConfigFiles hoogleLocal haskellLib pkgsBuildBuild evalPackages compiler;
82+
inherit hsPkgs ghcForComponent makeConfigFiles hoogleLocal haskellLib pkgsBuildBuild evalPackages compiler ghc;
8383
inherit (buildPackages) glibcLocales;
8484
};
8585

builder/shell-for.nix

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ lib, stdenv, mkShell, glibcLocales, ghcForComponent, makeConfigFiles, hsPkgs, hoogleLocal, haskellLib, pkgsBuildBuild, evalPackages, compiler }:
1+
{ lib, stdenv, mkShell, glibcLocales, ghcForComponent, makeConfigFiles, hsPkgs, hoogleLocal, haskellLib, pkgsBuildBuild, evalPackages, compiler, haskell-nix, ghc }:
22

33
{ # `packages` function selects packages that will be worked on in the shell itself.
44
# These packages will not be built by `shellFor`, but their
@@ -120,7 +120,10 @@ let
120120
# Set up a "dummy" component to use with ghcForComponent.
121121
component = {
122122
depends = packageInputs;
123-
pre-existing = lib.unique (lib.concatMap (x: (haskellLib.dependToLib x).pre-existing or []) allConfigs);
123+
pre-existing =
124+
if exactDeps
125+
then lib.unique (lib.concatMap (x: (haskellLib.dependToLib x).pre-existing or []) allConfigs)
126+
else haskell-nix.ghc-pre-existing ghc;
124127
libs = haskellLib.uniqueWithName (lib.concatMap (x: (haskellLib.dependToLib x).libs or []) allConfigs);
125128
pkgconfig = haskellLib.uniqueWithName (lib.concatMap (x: (haskellLib.dependToLib x).pkgconfig or []) allConfigs);
126129
frameworks = haskellLib.uniqueWithName (lib.concatMap (x: (haskellLib.dependToLib x).frameworks or []) allConfigs);

lib/call-cabal-project-to-nix.nix

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -366,57 +366,6 @@ let
366366
'';
367367
};
368368

369-
ghc-pkgs = [
370-
"Cabal"
371-
"array"
372-
"base"
373-
"binary"
374-
"bytestring"
375-
"containers"
376-
"deepseq"
377-
"directory"
378-
"filepath"
379-
"ghc-boot"
380-
"ghc-boot-th"
381-
"ghc-compact"
382-
"ghc-heap"
383-
"ghc-prim"
384-
"ghci"
385-
"integer-gmp"
386-
"mtl"
387-
"parsec"
388-
"pretty"
389-
"process"
390-
"rts"
391-
"template-haskell"
392-
"text"
393-
"time"
394-
"transformers"
395-
] ++ pkgs.lib.optionals (!pkgs.stdenv.targetPlatform.isGhcjs || builtins.compareVersions ghc.version "9.0" > 0) [
396-
# GHCJS 8.10 does not have these
397-
"Cabal-syntax"
398-
"exceptions"
399-
"file-io"
400-
"ghc"
401-
"ghc-bignum"
402-
"ghc-experimental"
403-
"ghc-internal"
404-
"ghc-platform"
405-
"ghc-toolchain"
406-
"haskeline"
407-
"hpc"
408-
"libiserv"
409-
"os-string"
410-
"semaphore-compat"
411-
"stm"
412-
"xhtml"
413-
] ++ pkgs.lib.optionals (!pkgs.stdenv.targetPlatform.isGhcjs) [
414-
"terminfo"
415-
] ++ (if pkgs.stdenv.targetPlatform.isWindows
416-
then [ "Win32" ]
417-
else [ "unix" ]
418-
);
419-
420369
dummy-ghc-pkg-dump = evalPackages.runCommand "dummy-ghc-pkg-dump" {
421370
nativeBuildInputs = [
422371
evalPackages.haskell-nix.nix-tools-unchecked.exes.cabal2json
@@ -557,7 +506,7 @@ let
557506
PKGS+=" ${name}"
558507
LAST_PKG="${name}"
559508
fi
560-
'') ghc-pkgs)
509+
'') (pkgs.haskell-nix.ghc-pre-existing ghc))
561510
}
562511
${ # There is no .cabal file for system-cxx-std-lib
563512
pkgs.lib.optionalString (builtins.compareVersions ghc.version "9.2" >= 0) (

overlays/haskell.nix

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,60 @@ final: prev: {
10741074
};
10751075
}) final.haskell-nix.compiler;
10761076

1077+
ghc-pre-existing = ghc: [
1078+
"Cabal"
1079+
"array"
1080+
"base"
1081+
"binary"
1082+
"bytestring"
1083+
"containers"
1084+
"deepseq"
1085+
"directory"
1086+
"filepath"
1087+
"ghc-boot"
1088+
"ghc-boot-th"
1089+
"ghc-compact"
1090+
"ghc-heap"
1091+
"ghc-prim"
1092+
"ghci"
1093+
"integer-gmp"
1094+
"mtl"
1095+
"parsec"
1096+
"pretty"
1097+
"process"
1098+
"rts"
1099+
"template-haskell"
1100+
"text"
1101+
"time"
1102+
"transformers"
1103+
] ++ final.lib.optionals (!final.stdenv.targetPlatform.isGhcjs || builtins.compareVersions ghc.version "9.0" > 0) [
1104+
# GHCJS 8.10 does not have these
1105+
"Cabal-syntax"
1106+
"exceptions"
1107+
"file-io"
1108+
"ghc"
1109+
"ghc-bignum"
1110+
"ghc-experimental"
1111+
"ghc-internal"
1112+
"ghc-platform"
1113+
"ghc-toolchain"
1114+
"haskeline"
1115+
"hpc"
1116+
"libiserv"
1117+
"os-string"
1118+
"semaphore-compat"
1119+
"stm"
1120+
"xhtml"
1121+
] ++ final.lib.optionals (
1122+
!final.stdenv.targetPlatform.isGhcjs
1123+
&& !final.stdenv.targetPlatform.isWindows
1124+
&& ghc.enableTerminfo or true) [
1125+
"terminfo"
1126+
] ++ (if final.stdenv.targetPlatform.isWindows
1127+
then [ "Win32" ]
1128+
else [ "unix" ]
1129+
);
1130+
10771131
# Add this to your tests to make all the dependencies of haskell.nix
10781132
# are tested and cached. Consider using `p.roots` where `p` is a
10791133
# project as it will automatically match the `compiler-nix-name`

0 commit comments

Comments
 (0)