blob: 3513b75672403b15858f7f959301df156da7a9f0 [file] [log] [blame]
Sergiusz Bazanskie03c2172020-02-15 01:04:38 +01001def _gen_imports_impl(ctx):
2 ctx.file("BUILD", "")
3
Sergiusz Bazanskic5a77b82020-02-17 23:04:35 +01004 if "hscloud_root" not in ctx.os.environ:
5 fail("Please souce env.sh")
6
7 is_nixos = "hscloud_nixos" in ctx.os.environ
Sergiusz Bazanskie03c2172020-02-15 01:04:38 +01008 bzl_file_content = """
9load(
10 "@io_bazel_rules_go//go:deps.bzl",
11 "go_register_toolchains",
12 "go_rules_dependencies",
13)
14def load_go_sdk():
15 go_rules_dependencies()
16 go_register_toolchains({go_version})
17 """.format(
18 go_version = 'go_version = "host"' if is_nixos else "",
19 )
20
21 ctx.file("imports.bzl", bzl_file_content)
22
23_gen_imports = repository_rule(
24 implementation = _gen_imports_impl,
25 attrs = dict(),
26)
27
28def gen_imports(name):
29 _gen_imports(
30 name = name,
31 )