Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

build: Add cargo timing script to devshell (#49941)

Cameron Mcloughlinbb271cf56259
diff --git a/nix/modules/devshells.nix b/nix/modules/devshells.nix
index 0acc0f8909e..cfc0e48b871 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 8226a2becdb..6ff91ff84a5 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;
}