@@ -564,7 +564,15 @@ def _rust_toolchain_tools_repository_impl(ctx):
564564 repro [key ] = getattr (ctx .attr , key )
565565 repro ["sha256s" ] = sha256s
566566
567- return repro
567+ # Bazel <8.3.0 lacks ctx.repo_metadata
568+ if not hasattr (ctx , "repo_metadata" ):
569+ return repro
570+
571+ reproducible = sha256s == dict (ctx .attr .sha256s )
572+ return ctx .repo_metadata (
573+ reproducible = reproducible ,
574+ attrs_for_reproducibility = {} if reproducible else repro ,
575+ )
568576
569577rust_toolchain_tools_repository = repository_rule (
570578 doc = (
@@ -834,7 +842,15 @@ def _rust_analyzer_toolchain_tools_repository_impl(repository_ctx):
834842 repro [key ] = getattr (repository_ctx .attr , key )
835843 repro ["sha256s" ] = sha256s
836844
837- return repro
845+ # Bazel <8.3.0 lacks ctx.repo_metadata
846+ if not hasattr (repository_ctx , "repo_metadata" ):
847+ return repro
848+
849+ reproducible = sha256s == dict (repository_ctx .attr .sha256s )
850+ return repository_ctx .repo_metadata (
851+ reproducible = reproducible ,
852+ attrs_for_reproducibility = {} if reproducible else repro ,
853+ )
838854
839855rust_analyzer_toolchain_tools_repository = repository_rule (
840856 doc = "A repository rule for defining a rust_analyzer_toolchain with a `rust-src` artifact." ,
@@ -979,7 +995,15 @@ def _rustfmt_toolchain_tools_repository_impl(repository_ctx):
979995 repro [key ] = getattr (repository_ctx .attr , key )
980996 repro ["sha256s" ] = sha256s
981997
982- return repro
998+ # Bazel <8.3.0 lacks ctx.repo_metadata
999+ if not hasattr (repository_ctx , "repo_metadata" ):
1000+ return repro
1001+
1002+ reproducible = sha256s == dict (repository_ctx .attr .sha256s )
1003+ return repository_ctx .repo_metadata (
1004+ reproducible = reproducible ,
1005+ attrs_for_reproducibility = {} if reproducible else repro ,
1006+ )
9831007
9841008rustfmt_toolchain_tools_repository = repository_rule (
9851009 doc = "A repository rule for defining a rustfmt_toolchain." ,
0 commit comments