Skip to content

Commit 51e35d5

Browse files
committed
Add dummy stack_asterius repository
1 parent b5ed035 commit 51e35d5

File tree

1 file changed

+36
-11
lines changed

1 file changed

+36
-11
lines changed

Diff for: rules_haskell_tests/non_module_deps_2.bzl

+36-11
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ load("@toolchains_libraries//:toolchain_libraries.bzl", "toolchain_libraries")
77

88
label_builder = lambda x: Label(x)
99

10+
def _empty_repo_impl(rctx):
11+
fail(rctx.attrs.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):
1125
# In a separate repo because not all platforms support zlib.
1226
stack_snapshot(
@@ -304,17 +318,28 @@ haskell_cabal_library(
304318
label_builder = label_builder,
305319
)
306320

307-
stack_snapshot(
308-
name = "stackage_asterius",
309-
setup_stack = False,
310-
local_snapshot = "//tests/asterius/stack_toolchain_libraries:snapshot.yaml",
311-
packages = [
312-
"xhtml",
313-
],
314-
stack_snapshot_json = "//tests/asterius/stack_toolchain_libraries:snapshot.json",
315-
toolchain_libraries = toolchain_libraries,
316-
label_builder = label_builder,
317-
) if is_linux else None
321+
if is_linux:
322+
stack_snapshot(
323+
name = "stackage_asterius",
324+
setup_stack = False,
325+
local_snapshot = "//tests/asterius/stack_toolchain_libraries:snapshot.yaml",
326+
packages = [
327+
"xhtml",
328+
],
329+
stack_snapshot_json = "//tests/asterius/stack_toolchain_libraries:snapshot.json",
330+
toolchain_libraries = toolchain_libraries,
331+
label_builder = label_builder,
332+
)
333+
else:
334+
# On non linux, we still need a dummy repository to call `use_repo` in the `MODULE.bazel` file.
335+
_empty_repo(
336+
name = "stackage_asterius",
337+
error_msg = "The stackage_asterius repository should only be used on linux",
338+
)
339+
_empty_repo(
340+
name = "stackage_asterius-unpinned",
341+
error_msg = "The stackage_asterius-unpinned repository should only be used on linux",
342+
)
318343

319344
def _non_module_deps_2_impl(ctx):
320345
repositories(bzlmod = True)

0 commit comments

Comments
 (0)