From bb271cf56259160b808ca80122180a7aabd59fb3 Mon Sep 17 00:00:00 2001 From: Cameron Mcloughlin Date: Tue, 24 Feb 2026 02:46:26 +0000 Subject: [PATCH] build: Add cargo timing script to devshell (#49941) --- nix/modules/devshells.nix | 10 ++++++++++ script/cargo | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/nix/modules/devshells.nix b/nix/modules/devshells.nix index 0acc0f8909ef51afd29c1b0cd7621d32915f5546..cfc0e48b871e71d87f9f794b35c16fed714ed4a9 100644 --- a/nix/modules/devshells.nix +++ b/nix/modules/devshells.nix @@ -18,6 +18,15 @@ # Musl cross-compiler for building remote_server muslCross = pkgs.pkgsCross.musl64; + + # Cargo build timings wrapper script + wrappedCargo = pkgs.writeShellApplication { + name = "cargo"; + runtimeInputs = [pkgs.nodejs]; + text = '' + NIX_WRAPPER=1 CARGO=${rustToolchain}/bin/cargo ./script/cargo "$@" + ''; + }; in { devShells.default = (pkgs.mkShell.override { inherit (zed-editor) stdenv; }) { @@ -25,6 +34,7 @@ inputsFrom = [ zed-editor ]; packages = with pkgs; [ + wrappedCargo # must be first, to shadow the `cargo` provided by `rustToolchain` rustToolchain # cargo, rustc, and rust-toolchain.toml components included cargo-nextest cargo-hakari diff --git a/script/cargo b/script/cargo index 8226a2becdbbcc27e5ad01b27f8479fea706fa5d..6ff91ff84a59ed4a6820c24cff3b83790dab3d21 100755 --- a/script/cargo +++ b/script/cargo @@ -209,6 +209,10 @@ async function main() { // Handle --init flag if (args[0] === "--init") { + if (process.env.NIX_WRAPPER === "1") { + console.error("`--init` not supported when going through the nix wrapper"); + process.exit(1); + } initShellAlias(); return; }