2023-05-12 14:17:16 +00:00
|
|
|
{ stdenv, lib, rustPlatform, rustc, Security, patchelf }:
|
2023-04-12 19:40:37 +00:00
|
|
|
|
2019-08-13 21:52:01 +00:00
|
|
|
rustPlatform.buildRustPackage {
|
2022-03-01 10:39:32 +00:00
|
|
|
pname = "clippy";
|
2023-05-12 14:17:16 +00:00
|
|
|
inherit (rustc) version src;
|
2019-08-15 14:13:01 +00:00
|
|
|
|
2023-04-12 19:55:28 +00:00
|
|
|
separateDebugInfo = true;
|
|
|
|
|
2019-08-15 14:13:01 +00:00
|
|
|
# the rust source tarball already has all the dependencies vendored, no need to fetch them again
|
|
|
|
cargoVendorDir = "vendor";
|
2020-05-12 23:28:24 +00:00
|
|
|
buildAndTestSubdir = "src/tools/clippy";
|
2019-08-15 14:13:01 +00:00
|
|
|
|
|
|
|
# changes hash of vendor directory otherwise
|
|
|
|
dontUpdateAutotoolsGnuConfigScripts = true;
|
|
|
|
|
2023-05-12 14:17:16 +00:00
|
|
|
buildInputs = [ rustc.llvm ]
|
2023-04-12 19:40:37 +00:00
|
|
|
++ lib.optionals stdenv.isDarwin [ Security ];
|
2019-08-15 14:13:01 +00:00
|
|
|
|
|
|
|
# fixes: error: the option `Z` is only accepted on the nightly compiler
|
|
|
|
RUSTC_BOOTSTRAP = 1;
|
|
|
|
|
|
|
|
# Without disabling the test the build fails with:
|
|
|
|
# error: failed to run custom build command for `rustc_llvm v0.0.0
|
|
|
|
# (/private/tmp/nix-build-clippy-1.36.0.drv-0/rustc-1.36.0-src/src/librustc_llvm)
|
|
|
|
doCheck = false;
|
|
|
|
|
2023-02-17 05:04:21 +00:00
|
|
|
# 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
|
2021-01-22 11:25:31 +00:00
|
|
|
preFixup = lib.optionalString stdenv.isDarwin ''
|
2023-05-12 14:17:16 +00:00
|
|
|
install_name_tool -add_rpath "${rustc}/lib" "$out/bin/clippy-driver"
|
|
|
|
install_name_tool -add_rpath "${rustc}/lib" "$out/bin/cargo-clippy"
|
2019-08-15 14:13:01 +00:00
|
|
|
'';
|
|
|
|
|
2021-01-22 11:25:31 +00:00
|
|
|
meta = with lib; {
|
2020-02-18 01:58:48 +00:00
|
|
|
homepage = "https://rust-lang.github.io/rust-clippy/";
|
2019-08-15 14:13:01 +00:00
|
|
|
description = "A bunch of lints to catch common mistakes and improve your Rust code";
|
2023-02-17 05:08:52 +00:00
|
|
|
maintainers = with maintainers; [ basvandijk ] ++ teams.rust.members;
|
2019-08-15 14:13:01 +00:00
|
|
|
license = with licenses; [ mit asl20 ];
|
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
|
|
|
}
|