clippy: fix on darwin

As of Rust 1.67.0, the cargo-clippy binary now relies on the rustc_private
libraries [0], so let's do the RPATH fixup to it too.

I've also added a comment to explain the RPATH situation, as it took me
a bit to figure out.

[0]: https://github.com/rust-lang/rust-clippy/pull/9541
This commit is contained in:
Winter 2023-02-17 00:04:21 -05:00
parent 8be63c2f94
commit 759bd7b26f

View file

@ -20,8 +20,15 @@ rustPlatform.buildRustPackage {
# (/private/tmp/nix-build-clippy-1.36.0.drv-0/rustc-1.36.0-src/src/librustc_llvm) # (/private/tmp/nix-build-clippy-1.36.0.drv-0/rustc-1.36.0-src/src/librustc_llvm)
doCheck = false; doCheck = false;
# Clippy uses the rustc_driver and std private libraries, and Rust's build process forces them to have
# an install name of `@rpath/...` [0] [1] instead of the standard on macOS, which is an absolute path
# to itself.
#
# [0]: https://github.com/rust-lang/rust/blob/f77f4d55bdf9d8955d3292f709bd9830c2fdeca5/src/bootstrap/builder.rs#L1543
# [1]: https://github.com/rust-lang/rust/blob/f77f4d55bdf9d8955d3292f709bd9830c2fdeca5/compiler/rustc_codegen_ssa/src/back/linker.rs#L323-L331
preFixup = lib.optionalString stdenv.isDarwin '' preFixup = lib.optionalString stdenv.isDarwin ''
install_name_tool -add_rpath "${rustc}/lib" $out/bin/clippy-driver install_name_tool -add_rpath "${rustc}/lib" "$out/bin/clippy-driver"
install_name_tool -add_rpath "${rustc}/lib" "$out/bin/cargo-clippy"
''; '';
meta = with lib; { meta = with lib; {