@@ -7,6 +7,20 @@ load("@toolchains_libraries//:toolchain_libraries.bzl", "toolchain_libraries")
7
7
8
8
label_builder = lambda x : Label (x )
9
9
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
+
10
24
def repositories (* , bzlmod ):
11
25
# In a separate repo because not all platforms support zlib.
12
26
stack_snapshot (
@@ -304,17 +318,28 @@ haskell_cabal_library(
304
318
label_builder = label_builder ,
305
319
)
306
320
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
+ )
318
343
319
344
def _non_module_deps_2_impl (ctx ):
320
345
repositories (bzlmod = True )
0 commit comments