1{
2 config,
3 pkgs,
4 haskellLib,
5}:
6
7with haskellLib;
8
9let
10 inherit (pkgs.stdenv.hostPlatform) isDarwin;
11 inherit (pkgs) lib;
12in
13
14self: super: {
15
16 # Disable GHC 9.2.x core libraries.
17 array = null;
18 base = null;
19 binary = null;
20 bytestring = null;
21 Cabal = null;
22 containers = null;
23 deepseq = null;
24 directory = null;
25 exceptions = null;
26 filepath = null;
27 ghc-bignum = null;
28 ghc-boot = null;
29 ghc-boot-th = null;
30 ghc-compact = null;
31 ghc-heap = null;
32 ghc-prim = null;
33 ghci = null;
34 haskeline = null;
35 hpc = null;
36 integer-gmp = null;
37 libiserv = null;
38 mtl = null;
39 parsec = null;
40 pretty = null;
41 process = null;
42 rts = null;
43 stm = null;
44 template-haskell = null;
45 # GHC only builds terminfo if it is a native compiler
46 terminfo =
47 if pkgs.stdenv.hostPlatform == pkgs.stdenv.buildPlatform then
48 null
49 else
50 doDistribute self.terminfo_0_4_1_7;
51 text = null;
52 time = null;
53 transformers = null;
54 unix = null;
55 # GHC only bundles the xhtml library if haddock is enabled, check if this is
56 # still the case when updating: https://gitlab.haskell.org/ghc/ghc/-/blob/0198841877f6f04269d6050892b98b5c3807ce4c/ghc.mk#L463
57 xhtml = if self.ghc.hasHaddock or true then null else doDistribute self.xhtml_3000_4_0_0;
58
59 # Need the Cabal-syntax-3.6.0.0 fake package for Cabal < 3.8 to allow callPackage and the constraint solver to work
60 Cabal-syntax = self.Cabal-syntax_3_6_0_0;
61 # These core package only exist for GHC >= 9.4. The best we can do is feign
62 # their existence to callPackages, but their is no shim for lower GHC versions.
63 system-cxx-std-lib = null;
64
65 # Becomes a core package in GHC >= 9.8
66 semaphore-compat = doDistribute self.semaphore-compat_1_0_0;
67
68 # weeder >= 2.5 requires GHC 9.4
69 weeder = doDistribute self.weeder_2_4_1;
70 # Allow dhall 1.42.*
71 weeder_2_4_1 = doJailbreak (
72 super.weeder_2_4_1.override {
73 # weeder < 2.6 only supports algebraic-graphs < 0.7
74 # We no longer have matching test deps for algebraic-graphs 0.6.1 in the set
75 algebraic-graphs = dontCheck self.algebraic-graphs_0_6_1;
76 }
77 );
78
79 haskell-language-server =
80 lib.throwIf config.allowAliases
81 "haskell-language-server has dropped support for ghc 9.2 in version 2.10.0.0, please use a newer ghc version or an older nixpkgs version"
82 (markBroken super.haskell-language-server);
83
84 # For GHC < 9.4, some packages need data-array-byte as an extra dependency
85 hashable = addBuildDepends [ self.data-array-byte ] super.hashable;
86 primitive = addBuildDepends [ self.data-array-byte ] super.primitive;
87 primitive-unlifted = super.primitive-unlifted_0_1_3_1;
88 # Too strict lower bound on base
89 primitive-addr = doJailbreak super.primitive-addr;
90
91 # Needs base-orphans for GHC < 9.8 / base < 4.19
92 some = addBuildDepend self.base-orphans super.some;
93
94 # Jailbreaks & Version Updates
95 hashable-time = doJailbreak super.hashable-time;
96
97 # Depends on utf8-light which isn't maintained / doesn't support base >= 4.16
98 # https://github.com/haskell-infra/hackage-trustees/issues/347
99 # https://mail.haskell.org/pipermail/haskell-cafe/2022-October/135613.html
100 language-javascript_0_7_0_0 = dontCheck super.language-javascript_0_7_0_0;
101
102 # Needs to match ghc-lib version
103 ghc-tags = doDistribute (doJailbreak self.ghc-tags_1_7);
104
105 # Needs to match ghc-lib
106 hlint = doDistribute self.hlint_3_6_1;
107
108 # ghc-lib >= 9.8 and friends no longer build with GHC 9.2 since they require semaphore-compat
109 ghc-lib-parser = doDistribute (
110 self.ghc-lib-parser_9_6_7_20250325.override {
111 happy = self.happy_1_20_1_1; # wants happy < 1.21
112 }
113 );
114 ghc-lib-parser-ex = doDistribute self.ghc-lib-parser-ex_9_6_0_2;
115 ghc-lib = doDistribute (
116 self.ghc-lib_9_6_7_20250325.override {
117 happy = self.happy_1_20_1_1; # wants happy < 1.21
118 }
119 );
120
121 # 0.2.2.3 requires Cabal >= 3.8
122 shake-cabal = doDistribute self.shake-cabal_0_2_2_2;
123
124 # Tests require nothunks < 0.3 (conflicting with Stackage) for GHC < 9.8
125 aeson = dontCheck super.aeson;
126
127 # https://github.com/NixOS/cabal2nix/issues/554
128 # https://github.com/clash-lang/clash-compiler/blob/f0f6275e19b8c672f042026c478484c5fd45191d/README.md#ghc-compatibility
129 clash-prelude = dontDistribute (markBroken super.clash-prelude);
130
131 # Too strict upper bound on bytestring, relevant for GHC 9.2.6 specifically
132 # https://github.com/protolude/protolude/issues/127#issuecomment-1428807874
133 protolude = doJailbreak super.protolude;
134
135 # https://github.com/fpco/inline-c/pull/131
136 inline-c-cpp =
137 (if isDarwin then appendConfigureFlags [ "--ghc-option=-fcompact-unwind" ] else x: x)
138 super.inline-c-cpp;
139
140 # A given major version of ghc-exactprint only supports one version of GHC.
141 ghc-exactprint = super.ghc-exactprint_1_5_0;
142
143 # only broken for >= 9.6
144 calligraphy = doDistribute (unmarkBroken super.calligraphy);
145
146 # Packages which need compat library for GHC < 9.6
147 inherit (lib.mapAttrs (_: addBuildDepends [ self.foldable1-classes-compat ]) super)
148 indexed-traversable
149 OneTuple
150 these
151 ;
152 base-compat-batteries = addBuildDepends [
153 self.foldable1-classes-compat
154 self.OneTuple
155 ] super.base-compat-batteries;
156}