blob: 1884c4278a57d1e0c314cd10b6052279b4de6583 [file] [log] [blame]
Sergiusz Bazanskie03c2172020-02-15 01:04:38 +01001def _gen_imports_impl(ctx):
2 ctx.file("BUILD", "")
3
4 is_nixos = "NIX_PATH" in ctx.os.environ
5 bzl_file_content = """
6load(
7 "@io_bazel_rules_go//go:deps.bzl",
8 "go_register_toolchains",
9 "go_rules_dependencies",
10)
11def load_go_sdk():
12 go_rules_dependencies()
13 go_register_toolchains({go_version})
14 """.format(
15 go_version = 'go_version = "host"' if is_nixos else "",
16 )
17
18 ctx.file("imports.bzl", bzl_file_content)
19
20_gen_imports = repository_rule(
21 implementation = _gen_imports_impl,
22 attrs = dict(),
23)
24
25def gen_imports(name):
26 _gen_imports(
27 name = name,
28 )