diff --git a/pkgs/development/compilers/rust/rustfmt-fix-self-tests.patch b/pkgs/development/compilers/rust/rustfmt-fix-self-tests.patch new file mode 100644 index 000000000000..b60332daef44 --- /dev/null +++ b/pkgs/development/compilers/rust/rustfmt-fix-self-tests.patch @@ -0,0 +1,13 @@ +--- a/src/tools/rustfmt/src/ignore_path.rs ++++ b/src/tools/rustfmt/src/ignore_path.rs +@@ -37,9 +37,9 @@ + #[nightly_only_test] + #[test] + fn test_ignore_path_set() { +- use std::path::{Path, PathBuf}; + use crate::config::{Config, FileName}; + use crate::ignore_path::IgnorePathSet; ++ use std::path::{Path, PathBuf}; + + let config = + Config::from_toml(r#"ignore = ["foo.rs", "bar_dir/*"]"#, Path::new("")).unwrap(); diff --git a/pkgs/development/compilers/rust/rustfmt.nix b/pkgs/development/compilers/rust/rustfmt.nix index f8ac8bf39df3..5916b6c07fb5 100644 --- a/pkgs/development/compilers/rust/rustfmt.nix +++ b/pkgs/development/compilers/rust/rustfmt.nix @@ -1,7 +1,7 @@ -{ lib, stdenv, rustPlatform, Security }: +{ lib, stdenv, rustPlatform, Security, asNightly ? false }: rustPlatform.buildRustPackage rec { - pname = "rustfmt"; + pname = "rustfmt" + lib.optionalString asNightly "-nightly"; inherit (rustPlatform.rust.rustc) version src; # the rust source tarball already has all the dependencies vendored, no need to fetch them again @@ -19,7 +19,10 @@ rustPlatform.buildRustPackage rec { # As of rustc 1.45.0, these env vars are required to build rustfmt (due to # https://github.com/rust-lang/rust/pull/72001) CFG_RELEASE = rustPlatform.rust.rustc.version; - CFG_RELEASE_CHANNEL = "stable"; + CFG_RELEASE_CHANNEL = if asNightly then "nightly" else "stable"; + + # FIXME: seems fixed upstream, remove after the next update + patches = [ ./rustfmt-fix-self-tests.patch ]; meta = with lib; { description = "A tool for formatting Rust code according to style guidelines"; diff --git a/pkgs/development/tools/rust/bindgen/unwrapped.nix b/pkgs/development/tools/rust/bindgen/unwrapped.nix index 65ce8e20bc0e..f77e2feb4ff3 100644 --- a/pkgs/development/tools/rust/bindgen/unwrapped.nix +++ b/pkgs/development/tools/rust/bindgen/unwrapped.nix @@ -1,9 +1,11 @@ -{ lib, fetchFromGitHub, rustPlatform, clang, rustfmt, writeTextFile +{ lib, fetchFromGitHub, rustPlatform, clang, rustfmt , runtimeShell , bash }: - -rustPlatform.buildRustPackage rec { +let + # bindgen hardcodes rustfmt outputs that use nightly features + rustfmt-nightly = rustfmt.override { asNightly = true; }; +in rustPlatform.buildRustPackage rec { pname = "rust-bindgen-unwrapped"; version = "0.59.2"; @@ -25,23 +27,10 @@ rustPlatform.buildRustPackage rec { ''; doCheck = true; - checkInputs = - let fakeRustup = writeTextFile { - name = "fake-rustup"; - executable = true; - destination = "/bin/rustup"; - text = '' - #!${runtimeShell} - shift - shift - exec "$@" - ''; - }; - in [ - rustfmt - fakeRustup # the test suite insists in calling `rustup run nightly rustfmt` - clang - ]; + checkInputs = [ clang ]; + + RUSTFMT = "${rustfmt-nightly}/bin/rustfmt"; + preCheck = '' # for the ci folder, notably patchShebangs .