Skip to content

Commit 63991b8

Browse files
committed
Skip Cabal in setup_deps for GHC 9.6
1 parent a043e79 commit 63991b8

File tree

4 files changed

+47
-24
lines changed

4 files changed

+47
-24
lines changed

WORKSPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ stack_snapshot(
179179
"proto-lens-runtime",
180180
"lens-family",
181181
],
182-
setup_deps = {
182+
setup_deps = {} if GHC_VERSION and GHC_VERSION.startswith("9.6.") else {
183183
# See https://github.com/tweag/rules_haskell/issues/1871
184184
"HUnit": ["@Cabal//:Cabal"],
185185
"bifunctors": ["@Cabal//:Cabal"],

extensions/rules_haskell_dependencies.bzl

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
77
load("@rules_haskell//tools:os_info.bzl", "os_info")
88
load("@rules_haskell_ghc_version//:ghc_version.bzl", "GHC_VERSION")
99

10+
def _empty_repo_impl(rctx):
11+
fail(rctx.attr.error_msg)
12+
13+
_empty_repo = repository_rule(
14+
implementation = _empty_repo_impl,
15+
doc = """A dummy repository that can be loaded from the MODULE.bazel file but not fetched.""",
16+
attrs = {
17+
"error_msg": attr.string(
18+
doc = "The error message displayed if the repository is fetched",
19+
mandatory = True,
20+
),
21+
},
22+
)
23+
1024
def repositories(*, bzlmod): # @unused
1125
rules_haskell_dependencies_bzlmod()
1226

@@ -24,7 +38,12 @@ def repositories(*, bzlmod): # @unused
2438

2539
# TODO: Remove when tests are run with a ghc version containing Cabal >= 3.10
2640
# See https://github.com/tweag/rules_haskell/issues/1871
27-
if GHC_VERSION and GHC_VERSION.startswith("9.4."):
41+
if GHC_VERSION and GHC_VERSION.startswith("9.6."):
42+
_empty_repo(
43+
name = "Cabal",
44+
error_msg = "When using GHC >= 9.6, do not depend on @Cabal, as https://github.com/tweag/rules_haskell/issues/1871 is fixed.",
45+
)
46+
elif GHC_VERSION and GHC_VERSION.startswith("9.4."):
2847
http_archive(
2948
name = "Cabal",
3049
build_file_content = """

rules_haskell_tests/WORKSPACE

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -273,27 +273,31 @@ stack_snapshot(
273273
"temporary",
274274
],
275275
setup_deps = {
276-
"polysemy": ["cabal-doctest"],
277-
# See https://github.com/tweag/rules_haskell/issues/1871
278-
"HUnit": ["@Cabal//:Cabal"],
279-
"bifunctors": ["@Cabal//:Cabal"],
280-
"c2hs": ["@Cabal//:Cabal"],
281-
"call-stack": ["@Cabal//:Cabal"],
282-
"doctest": ["@Cabal//:Cabal"],
283-
"generic-deriving": ["@Cabal//:Cabal"],
284-
"happy": ["@Cabal//:Cabal"],
285-
"hspec": ["@Cabal//:Cabal"],
286-
"hspec-core": ["@Cabal//:Cabal"],
287-
"hspec-discover": ["@Cabal//:Cabal"],
288-
"hspec-expectations": ["@Cabal//:Cabal"],
289-
"mono-traversable": ["@Cabal//:Cabal"],
290-
"proto-lens-protoc": ["@Cabal//:Cabal"],
291-
"proto-lens-runtime": ["@Cabal//:Cabal"],
292-
"quickcheck-io": ["@Cabal//:Cabal"],
293-
"transformers-compat": ["@Cabal//:Cabal"],
294-
"type-errors": ["@Cabal//:Cabal"],
295-
"typed-process": ["@Cabal//:Cabal"],
296-
"unliftio-core": ["@Cabal//:Cabal"],
276+
name: deps
277+
for name, deps in {
278+
"polysemy": ["cabal-doctest"],
279+
# See https://github.com/tweag/rules_haskell/issues/1871
280+
"HUnit": ["@Cabal//:Cabal"],
281+
"bifunctors": ["@Cabal//:Cabal"],
282+
"c2hs": ["@Cabal//:Cabal"],
283+
"call-stack": ["@Cabal//:Cabal"],
284+
"doctest": ["@Cabal//:Cabal"],
285+
"generic-deriving": ["@Cabal//:Cabal"],
286+
"happy": ["@Cabal//:Cabal"],
287+
"hspec": ["@Cabal//:Cabal"],
288+
"hspec-core": ["@Cabal//:Cabal"],
289+
"hspec-discover": ["@Cabal//:Cabal"],
290+
"hspec-expectations": ["@Cabal//:Cabal"],
291+
"mono-traversable": ["@Cabal//:Cabal"],
292+
"proto-lens-protoc": ["@Cabal//:Cabal"],
293+
"proto-lens-runtime": ["@Cabal//:Cabal"],
294+
"quickcheck-io": ["@Cabal//:Cabal"],
295+
"transformers-compat": ["@Cabal//:Cabal"],
296+
"type-errors": ["@Cabal//:Cabal"],
297+
"typed-process": ["@Cabal//:Cabal"],
298+
"unliftio-core": ["@Cabal//:Cabal"],
299+
}.items()
300+
if [d for d in deps if d != "@Cabal//:Cabal"] or not GHC_VERSION or not GHC_VERSION.startswith("9.6.")
297301
},
298302
stack_snapshot_json = "//:stackage_snapshot{}.json".format(
299303
"_" + str(GHC_VERSION) if GHC_VERSION else "",

tools/repositories.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def rules_haskell_worker_dependencies(**stack_kwargs):
2929
"text",
3030
"vector",
3131
],
32-
setup_deps = {
32+
setup_deps = {} if GHC_VERSION and GHC_VERSION.startswith("9.6.") else {
3333
"bifunctors": ["@Cabal//:Cabal"],
3434
"proto-lens-runtime": ["@Cabal//:Cabal"],
3535
"transformers-compat": ["@Cabal//:Cabal"],

0 commit comments

Comments
 (0)