about summary refs log tree commit diff
path: root/pkgs/development/tools/build-managers/bazel/bazel_7/java_toolchain.patch
blob: fa7bed8ac15139f8c6e40350bb031b8022baecc0 (plain) (blame)
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
diff --git a/tools/jdk/BUILD.tools b/tools/jdk/BUILD.tools
index a8af76e90c..7f8b030f63 100644
--- a/tools/jdk/BUILD.tools
+++ b/tools/jdk/BUILD.tools
@@ -146,6 +146,25 @@ py_test(
     ],
 )
 
+##### Nonprebuilt toolchains definitions for NixOS and nix build sandboxes ####
+
+load("@rules_java//toolchains:default_java_toolchain.bzl", "default_java_toolchain", "NONPREBUILT_TOOLCHAIN_CONFIGURATION")
+
+[
+    default_java_toolchain(
+        name = "nonprebuilt_toolchain_java" + str(version),
+        configuration = NONPREBUILT_TOOLCHAIN_CONFIGURATION,
+        java_runtime = "@local_jdk//:jdk",
+        source_version = str(version),
+        target_version = str(version),
+    )
+    # Ideally we would only define toolchains for the java versions that the
+    # local jdk supports. But we cannot access this information in a BUILD
+    # file, and this is a hack anyway, so just pick a large enough upper bound.
+    # At the current pace, java <= 30 should cover all realeases until 2028.
+    for version in range(8, 31)
+]
+
 #### Aliases to rules_java to keep backward-compatibility (begin) ####
 
 TARGET_NAMES = [