-
Notifications
You must be signed in to change notification settings - Fork 81
/
non_module_dev_deps.bzl
135 lines (114 loc) · 3.89 KB
/
non_module_dev_deps.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
""" External repositories for the CI that need to be shared between WORKSPACE and MODULE.bazel files """
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load(
"@rules_haskell//:constants.bzl",
_default_ghc_version = "test_ghc_version",
)
load(
"@rules_haskell//docs/pandoc:pandoc.bzl",
"import_pandoc_bindists",
"nixpkgs_pandoc_configure",
)
load(
"@rules_haskell//haskell:nixpkgs.bzl",
"haskell_register_ghc_nixpkgs",
)
load("@rules_haskell//tools:os_info.bzl", "os_info")
load("@rules_haskell_ghc_version//:ghc_version.bzl", "GHC_VERSION")
load("@rules_nixpkgs_cc//:cc.bzl", "nixpkgs_cc_configure")
load(
"@rules_nixpkgs_core//:nixpkgs.bzl",
"nixpkgs_local_repository",
"nixpkgs_package",
)
load("@rules_nixpkgs_go//:go.bzl", "nixpkgs_go_configure")
load("@rules_nixpkgs_python//:python.bzl", "nixpkgs_python_configure")
test_ghc_version = GHC_VERSION or _default_ghc_version
# Replaces local_repository in bzlmod
# See https://groups.google.com/g/bazel-discuss/c/xpsg3mWQPZg
def _starlarkified_local_repository_impl(repository_ctx):
relative_path = repository_ctx.attr.path
workspace_root = repository_ctx.path(Label("@//:MODULE.bazel")).dirname
absolute_path = workspace_root
for segment in relative_path.split("/"):
absolute_path = absolute_path.get_child(segment)
repository_ctx.symlink(absolute_path, ".")
starlarkified_local_repository = repository_rule(
implementation = _starlarkified_local_repository_impl,
attrs = {
"path": attr.string(mandatory = True),
},
)
def repositories(*, bzlmod):
# Some helpers for platform-dependent configuration
os_info(name = "os_info")
starlarkified_local_repository(
name = "tutorial",
path = "tutorial",
)
starlarkified_local_repository(
name = "examples",
path = "examples",
)
starlarkified_local_repository(
name = "examples-arm",
path = "examples/arm",
)
# no modules are provided at the moment for buildifier
http_archive(
name = "com_github_bazelbuild_buildtools",
sha256 = "60a9025072ae237f325d0e7b661e1685f34922c29883888c2d06f5789462b939",
strip_prefix = "buildtools-7.1.1",
urls = ["https://github.com/bazelbuild/buildtools/archive/v7.1.1.tar.gz"],
)
nixpkgs_local_repository(
name = "nixpkgs_default",
nix_file = "//nixpkgs:default.nix",
)
haskell_register_ghc_nixpkgs(
attribute_path = "",
nix_file_content = """with import <nixpkgs> {{}}; haskell.packages.ghc{version}.ghc""".format(
version = test_ghc_version.replace(".", ""),
),
repository = "@nixpkgs_default",
version = test_ghc_version,
register = not bzlmod,
)
nixpkgs_python_configure(
repository = "@nixpkgs_default",
register = not bzlmod,
)
nixpkgs_go_configure(
sdk_name = "nixpkgs_go_sdk",
repository = "@nixpkgs_default",
register = not bzlmod,
rules_go_repo_name = "io_bazel_rules_go",
)
nixpkgs_cc_configure(
# Don't override the default cc toolchain needed for bindist mode.
name = "nixpkgs_config_cc",
repository = "@nixpkgs_default",
register = not bzlmod,
)
nixpkgs_package(
name = "zip",
attribute_path = "zip",
repository = "@nixpkgs_default",
)
nixpkgs_package(
name = "graphviz",
attribute_path = "graphviz",
repository = "@nixpkgs_default",
)
nixpkgs_package(
name = "sphinx",
attribute_path = "python3Packages.sphinx",
repository = "@nixpkgs_default",
)
nixpkgs_pandoc_configure(repository = "@nixpkgs_default")
import_pandoc_bindists()
def _non_module_dev_deps_impl(_ctx):
repositories(bzlmod = True)
non_module_dev_deps = module_extension(
implementation = _non_module_dev_deps_impl,
)