From 2dfc1637973f0212ac1ee385e995513c9564dae8 Mon Sep 17 00:00:00 2001 From: Wim Looman Date: Thu, 2 May 2024 22:07:42 +0200 Subject: [PATCH] Replace rust-wrapper with RUSTC_FORCE_RUSTC_VERSION Requires https://github.com/rust-lang/rust/pull/124339 but drastically simplifies evading nightly-detection --- shells/rust/default.nix | 8 +++++--- shells/rust/wrap-rust.nix | 34 ---------------------------------- 2 files changed, 5 insertions(+), 37 deletions(-) delete mode 100644 shells/rust/wrap-rust.nix diff --git a/shells/rust/default.nix b/shells/rust/default.nix index 528ce5f..20a515d 100644 --- a/shells/rust/default.nix +++ b/shells/rust/default.nix @@ -1,6 +1,5 @@ { pkgs, lib, ... }: let - wrap-rust = pkgs.callPackage ./wrap-rust.nix {}; setup-xdg-cargo-home = pkgs.writeShellApplication { name = "setup-xdg-cargo-home"; text = lib.readFile ./setup-xdg-cargo-home; @@ -40,10 +39,12 @@ in { } )), custom ? true, -}: pkgs.mkShell { +}: let + version = lib.lists.head (lib.strings.split "-" rust-toolchain.version); +in pkgs.mkShell { buildInputs = with pkgs; [ # Rust itself - (if custom then (wrap-rust rust-toolchain) else rust-toolchain) + rust-toolchain # Dev utilities bacon @@ -130,5 +131,6 @@ in { # Some crates disable nightly feature detection when this is set export RUSTC_STAGE=1 + export RUSTC_FORCE_RUSTC_VERSION=${version} '' else ""); } diff --git a/shells/rust/wrap-rust.nix b/shells/rust/wrap-rust.nix deleted file mode 100644 index 62398a4..0000000 --- a/shells/rust/wrap-rust.nix +++ /dev/null @@ -1,34 +0,0 @@ -{ pkgs, ... }: rust-toolchain: -let - rustc-wrapped = pkgs.writeShellApplication { - name = "rustc"; - runtimeInputs = [ pkgs.gnused ]; - text = '' - is_version() { - while [ $# -gt 0 ] - do - case "$1" in - -V | -vV | -Vv | --version) - return 0 - ;; - esac - shift - done - return 1 - } - - if is_version "$@" - then - ${rust-toolchain}/bin/rustc "$@" | sed 's/-nightly//g' - else - exec ${rust-toolchain}/bin/rustc "$@" - fi - ''; - }; -in pkgs.symlinkJoin { - inherit (rust-toolchain) name; - paths = [ - rustc-wrapped - rust-toolchain - ]; -}