1{
2 stdenv,
3 lib,
4 rustPlatform,
5 rustc,
6}:
7
8rustPlatform.buildRustPackage {
9 pname = "clippy";
10 inherit (rustc) version src;
11
12 separateDebugInfo = true;
13
14 # the rust source tarball already has all the dependencies vendored, no need to fetch them again
15 cargoVendorDir = "vendor";
16 buildAndTestSubdir = "src/tools/clippy";
17
18 # changes hash of vendor directory otherwise
19 dontUpdateAutotoolsGnuConfigScripts = true;
20
21 buildInputs = [ rustc.llvm ];
22
23 # fixes: error: the option `Z` is only accepted on the nightly compiler
24 RUSTC_BOOTSTRAP = 1;
25
26 # Without disabling the test the build fails with:
27 # error: failed to run custom build command for `rustc_llvm v0.0.0
28 # (/private/tmp/nix-build-clippy-1.36.0.drv-0/rustc-1.36.0-src/src/librustc_llvm)
29 doCheck = false;
30
31 # Clippy uses the rustc_driver and std private libraries, and Rust's build process forces them to have
32 # an install name of `@rpath/...` [0] [1] instead of the standard on macOS, which is an absolute path
33 # to itself.
34 #
35 # [0]: https://github.com/rust-lang/rust/blob/f77f4d55bdf9d8955d3292f709bd9830c2fdeca5/src/bootstrap/builder.rs#L1543
36 # [1]: https://github.com/rust-lang/rust/blob/f77f4d55bdf9d8955d3292f709bd9830c2fdeca5/compiler/rustc_codegen_ssa/src/back/linker.rs#L323-L331
37 preFixup = lib.optionalString stdenv.hostPlatform.isDarwin ''
38 install_name_tool -add_rpath "${rustc.unwrapped}/lib" "$out/bin/clippy-driver"
39 install_name_tool -add_rpath "${rustc.unwrapped}/lib" "$out/bin/cargo-clippy"
40 '';
41
42 meta = with lib; {
43 homepage = "https://rust-lang.github.io/rust-clippy/";
44 description = "Bunch of lints to catch common mistakes and improve your Rust code";
45 mainProgram = "cargo-clippy";
46 maintainers = with maintainers; [ basvandijk ];
47 teams = [ teams.rust ];
48 license = with licenses; [
49 mit
50 asl20
51 ];
52 platforms = platforms.unix;
53 };
54}