2024-09-19 14:19:46 +00:00
|
|
|
{ stdenv, lib, rustPlatform, rustc, Security }:
|
2023-04-29 16:46:19 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
rustPlatform.buildRustPackage {
|
2022-03-10 19:12:11 +00:00
|
|
|
pname = "clippy";
|
2023-05-24 13:37:59 +00:00
|
|
|
inherit (rustc) version src;
|
2023-04-29 16:46:19 +00:00
|
|
|
|
|
|
|
separateDebugInfo = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# the rust source tarball already has all the dependencies vendored, no need to fetch them again
|
|
|
|
cargoVendorDir = "vendor";
|
2020-06-18 07:06:33 +00:00
|
|
|
buildAndTestSubdir = "src/tools/clippy";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# changes hash of vendor directory otherwise
|
|
|
|
dontUpdateAutotoolsGnuConfigScripts = true;
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
buildInputs = [ rustc.llvm ]
|
2023-04-29 16:46:19 +00:00
|
|
|
++ lib.optionals stdenv.isDarwin [ Security ];
|
2020-04-24 23:36:52 +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-22 10:55:15 +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-02-05 17:12:51 +00:00
|
|
|
preFixup = lib.optionalString stdenv.isDarwin ''
|
2024-01-02 11:29:13 +00:00
|
|
|
install_name_tool -add_rpath "${rustc.unwrapped}/lib" "$out/bin/clippy-driver"
|
|
|
|
install_name_tool -add_rpath "${rustc.unwrapped}/lib" "$out/bin/cargo-clippy"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://rust-lang.github.io/rust-clippy/";
|
2024-06-20 14:57:18 +00:00
|
|
|
description = "Bunch of lints to catch common mistakes and improve your Rust code";
|
2024-02-07 01:22:34 +00:00
|
|
|
mainProgram = "cargo-clippy";
|
2023-02-22 10:55:15 +00:00
|
|
|
maintainers = with maintainers; [ basvandijk ] ++ teams.rust.members;
|
2020-04-24 23:36:52 +00:00
|
|
|
license = with licenses; [ mit asl20 ];
|
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
|
|
|
}
|