···11+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
22+From: Luke Granger-Brown <git@lukegb.com>
33+Date: Thu, 17 Apr 2025 02:40:18 +0100
44+Subject: [PATCH] nixpkgs: bump rules_rust to 0.60.0
55+66+Signed-off-by: Luke Granger-Brown <git@lukegb.com>
77+---
88+ bazel/repository_locations.bzl | 6 +++---
99+ 1 file changed, 3 insertions(+), 3 deletions(-)
1010+1111+diff --git a/bazel/repository_locations.bzl b/bazel/repository_locations.bzl
1212+index 6904bc93bdda3ee2308f13d61e62295fa11d799b..e4574878a566cceb4dc2343f3cade0350ea5e5ff 100644
1313+--- a/bazel/repository_locations.bzl
1414++++ b/bazel/repository_locations.bzl
1515+@@ -1465,8 +1465,8 @@ REPOSITORY_LOCATIONS_SPEC = dict(
1616+ project_name = "Bazel rust rules",
1717+ project_desc = "Bazel rust rules (used by Wasm)",
1818+ project_url = "https://github.com/bazelbuild/rules_rust",
1919+- version = "0.56.0",
2020+- sha256 = "f1306aac0b258b790df01ad9abc6abb0df0b65416c74b4ef27f4aab298780a64",
2121++ version = "0.60.0",
2222++ sha256 = "7825214ccad7c2482cb490ac91dbc1e88b30223062796ce328aca893b74ae342",
2323+ # Note: rules_rust should point to the releases, not archive to avoid the hassle of bootstrapping in crate_universe.
2424+ # This is described in https://bazelbuild.github.io/rules_rust/crate_universe.html#setup, otherwise bootstrap
2525+ # is required which in turn requires a system CC toolchains, not the bazel controlled ones.
2626+@@ -1477,7 +1477,7 @@ REPOSITORY_LOCATIONS_SPEC = dict(
2727+ "dataplane_ext",
2828+ ],
2929+ extensions = ["envoy.wasm.runtime.wasmtime"],
3030+- release_date = "2024-12-16",
3131++ release_date = "2025-04-08",
3232+ cpe = "N/A",
3333+ license = "Apache-2.0",
3434+ license_url = "https://github.com/bazelbuild/rules_rust/blob/{version}/LICENSE.txt",
+21-6
pkgs/by-name/en/envoy/package.nix
···3434 # However, the version string is more useful for end-users.
3535 # These are contained in a attrset of their own to make it obvious that
3636 # people should update both.
3737- version = "1.33.0";
3838- rev = "b0f43d67aa25c1b03c97186a200cc187f4c22db3";
3939- hash = "sha256-zqekRpOlaA2IrwwFUEwASa1uokET98h5sr7EwzWgcbU=";
3737+ version = "1.34.0";
3838+ rev = "d7809ba2b07fd869d49bfb122b27f6a7977b4d94";
3939+ hash = "sha256-SKdUrBXe0E3fMo73NROFO9Ck5FZidF/awP+QRA5t3VM=";
4040 };
41414242 # these need to be updated for any changes to fetchAttrs
4343 depsHash =
4444 {
4545- x86_64-linux = "sha256-4CQkHlXbDpRiqzeyserVf9PpLx3ME7TtZ2H88ggog6U=";
4646- aarch64-linux = "sha256-FxkfBWiG0NIInl28w+l4YvaV2VFuCtjn5VBAKvJoxM8=";
4545+ x86_64-linux = "sha256-CiP9qH8/+nNZM8BNz84eVwWphVyDNo2KOYcK0wOsXn0=";
4646+ aarch64-linux = "sha256-9HGg68R546JY1EOm22tg9CuPt0nU+FooFcLG9A2hkzE=";
4747 }
4848 .${stdenv.system} or (throw "unsupported system ${stdenv.system}");
4949···5959 repo = "envoy";
6060 inherit (srcVer) hash rev;
6161 };
6262+ # By convention, these patches are generated like:
6363+ # git format-patch --zero-commit --signoff --no-numbered --minimal --full-index --no-signature
6264 patches = [
6365 # use system Python, not bazel-fetched binary Python
6466 ./0001-nixpkgs-use-system-Python.patch
···68706971 # use system C/C++ tools
7072 ./0003-nixpkgs-use-system-C-C-toolchains.patch
7373+7474+ # bump rules_rust to support newer Rust
7575+ ./0004-nixpkgs-bump-rules_rust-to-0.60.0.patch
7176 ];
7277 postPatch = ''
7378 chmod -R +w .
···9196 substituteInPlace bazel/dependency_imports.bzl \
9297 --replace-fail 'crate_universe_dependencies()' 'crate_universe_dependencies(rust_toolchain_cargo_template="@@//bazel/nix:cargo", rust_toolchain_rustc_template="@@//bazel/nix:rustc")' \
9398 --replace-fail 'crates_repository(' 'crates_repository(rust_toolchain_cargo_template="@@//bazel/nix:cargo", rust_toolchain_rustc_template="@@//bazel/nix:rustc",'
9999+100100+ # patch rules_rust for envoy specifics, but also to support old Bazel
101101+ # (Bazel 6 doesn't have ctx.watch, but ctx.path is sufficient for our use)
102102+ cp ${./rules_rust.patch} bazel/rules_rust.patch
103103+ substituteInPlace bazel/repositories.bzl \
104104+ --replace-fail ', "@envoy//bazel:rules_rust_ppc64le.patch"' ""
9410595106 substitute ${./rules_rust_extra.patch} bazel/nix/rules_rust_extra.patch \
96107 --subst-var-by bash "$(type -p bash)"
···133144 sed -i \
134145 -e 's,${python3},__NIXPYTHON__,' \
135146 -e 's,${stdenv.shellPackage},__NIXSHELL__,' \
147147+ -e 's,${builtins.storeDir}/[^/]\+/bin/bash,__NIXBASH__,' \
136148 $bazelOut/external/com_github_luajit_luajit/build.py \
137149 $bazelOut/external/local_config_sh/BUILD \
138150 $bazelOut/external/*_pip3/BUILD.bazel \
···180192 sed -i \
181193 -e 's,__NIXPYTHON__,${python3},' \
182194 -e 's,__NIXSHELL__,${stdenv.shellPackage},' \
195195+ -e 's,__NIXBASH__,${stdenv.shell},' \
183196 $bazelOut/external/com_github_luajit_luajit/build.py \
184197 $bazelOut/external/local_config_sh/BUILD \
185185- $bazelOut/external/*_pip3/BUILD.bazel
198198+ $bazelOut/external/*_pip3/BUILD.bazel \
199199+ $bazelOut/external/rules_rust/util/process_wrapper/private/process_wrapper.sh \
200200+ $bazelOut/external/rules_rust/crate_universe/src/metadata/cargo_tree_rustc_wrapper.sh
186201187202 # Install repinned rules_rust lockfile
188203 cp $bazelOut/external/Cargo.Bazel.lock source/extensions/dynamic_modules/sdk/rust/Cargo.Bazel.lock
+101
pkgs/by-name/en/envoy/rules_rust.patch
···11+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
22+From: Luke Granger-Brown <git@lukegb.com>
33+Date: Thu, 17 Apr 2025 02:44:24 +0100
44+Subject: [PATCH] rules_rust base
55+66+Signed-off-by: Luke Granger-Brown <git@lukegb.com>
77+---
88+ cargo/private/cargo_bootstrap.bzl | 8 ++++----
99+ crate_universe/extensions.bzl | 10 +++++-----
1010+ crate_universe/src/lockfile.rs | 4 ++--
1111+ rust/private/rustc.bzl | 4 ++--
1212+ 4 files changed, 13 insertions(+), 13 deletions(-)
1313+1414+diff --git cargo/private/cargo_bootstrap.bzl cargo/private/cargo_bootstrap.bzl
1515+index a8021c49d62037ef32c7c64d5bb4a5efe3a8b4aa..f63d7c23ae0bddc9f3fece347a3a2b5b0afe6d8d 100644
1616+--- cargo/private/cargo_bootstrap.bzl
1717++++ cargo/private/cargo_bootstrap.bzl
1818+@@ -173,13 +173,13 @@ def _detect_changes(repository_ctx):
1919+ # 'consumed' which means changes to it will trigger rebuilds
2020+2121+ for src in repository_ctx.attr.srcs:
2222+- repository_ctx.watch(src)
2323++ repository_ctx.path(src)
2424+2525+- repository_ctx.watch(repository_ctx.attr.cargo_lockfile)
2626+- repository_ctx.watch(repository_ctx.attr.cargo_toml)
2727++ repository_ctx.path(repository_ctx.attr.cargo_lockfile)
2828++ repository_ctx.path(repository_ctx.attr.cargo_toml)
2929+3030+ if repository_ctx.attr.cargo_config:
3131+- repository_ctx.watch(repository_ctx.attr.cargo_config)
3232++ repository_ctx.path(repository_ctx.attr.cargo_config)
3333+3434+ def _cargo_bootstrap_repository_impl(repository_ctx):
3535+ # Pretend to Bazel that this rule's input files have been used, so that it will re-run the rule if they change.
3636+diff --git crate_universe/extensions.bzl crate_universe/extensions.bzl
3737+index a749b10c8d469bd316d78034059c94b1fd98dbef..8f8c84dac1ec330d5e8e6abbd930387cb6c9f29e 100644
3838+--- crate_universe/extensions.bzl
3939++++ crate_universe/extensions.bzl
4040+@@ -957,17 +957,17 @@ def _crate_impl(module_ctx):
4141+ fail("Spec specified for repo {}, but the module defined repositories {}".format(repo, local_repos))
4242+4343+ for cfg in mod.tags.from_cargo + mod.tags.from_specs:
4444+- # Preload all external repositories. Calling `module_ctx.watch` will cause restarts of the implementation
4545++ # Preload all external repositories. Calling `module_ctx.path` will cause restarts of the implementation
4646+ # function of the module extension when the file has changed.
4747+ if cfg.cargo_lockfile:
4848+- module_ctx.watch(cfg.cargo_lockfile)
4949++ module_ctx.path(cfg.cargo_lockfile)
5050+ if cfg.lockfile:
5151+- module_ctx.watch(cfg.lockfile)
5252++ module_ctx.path(cfg.lockfile)
5353+ if cfg.cargo_config:
5454+- module_ctx.watch(cfg.cargo_config)
5555++ module_ctx.path(cfg.cargo_config)
5656+ if hasattr(cfg, "manifests"):
5757+ for m in cfg.manifests:
5858+- module_ctx.watch(m)
5959++ module_ctx.path(m)
6060+6161+ cargo_path, rustc_path = _get_host_cargo_rustc(module_ctx, host_triple, cfg.host_tools_repo)
6262+ cargo_bazel_fn = new_cargo_bazel_fn(
6363+diff --git crate_universe/src/lockfile.rs crate_universe/src/lockfile.rs
6464+index 3e0ce6265fda6fbdd9e3e989e3e4e4443b615b8c..0fafcea8fbc7a590676d34d2c4ca8c413b953955 100644
6565+--- crate_universe/src/lockfile.rs
6666++++ crate_universe/src/lockfile.rs
6767+@@ -146,10 +146,10 @@ impl Digest {
6868+ ));
6969+ hasher.update(b"\0");
7070+7171+- hasher.update(Digest::compute_single_hash(cargo_version, "Cargo version"));
7272++ hasher.update(Digest::compute_single_hash("hermetic", "Cargo version"));
7373+ hasher.update(b"\0");
7474+7575+- hasher.update(Digest::compute_single_hash(rustc_version, "Rustc version"));
7676++ hasher.update(Digest::compute_single_hash("hermetic", "Rustc version"));
7777+ hasher.update(b"\0");
7878+7979+ let hash = hasher.finalize().encode_hex::<String>();
8080+diff --git rust/private/rustc.bzl rust/private/rustc.bzl
8181+index d78c28902c8f73ae655b8f6b5df3db5a1805aa19..321a24a946c33d5e3452758a72a77b52d5a3eccf 100644
8282+--- rust/private/rustc.bzl
8383++++ rust/private/rustc.bzl
8484+@@ -1059,7 +1059,7 @@ def construct_arguments(
8585+8686+ if toolchain.llvm_cov and ctx.configuration.coverage_enabled:
8787+ # https://doc.rust-lang.org/rustc/instrument-coverage.html
8888+- rustc_flags.add("--codegen=instrument-coverage")
8989++ pass
9090+9191+ if toolchain._experimental_link_std_dylib:
9292+ rustc_flags.add("--codegen=prefer-dynamic")
9393+@@ -1563,7 +1563,7 @@ def rustc_compile_action(
9494+ })
9595+ crate_info = rust_common.create_crate_info(**crate_info_dict)
9696+9797+- if crate_info.type in ["staticlib", "cdylib"]:
9898++ if crate_info.type in ["staticlib", "cdylib"] and not out_binary:
9999+ # These rules are not supposed to be depended on by other rust targets, and
100100+ # as such they shouldn't provide a CrateInfo. However, one may still want to
101101+ # write a rust_test for them, so we provide the CrateInfo wrapped in a provider