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