nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 112 lines 2.9 kB view raw
1{ 2 lib, 3 stdenv, 4 pkgsHostHost, 5 file, 6 curl, 7 pkg-config, 8 python3, 9 openssl, 10 cmake, 11 zlib, 12 installShellFiles, 13 makeWrapper, 14 rustPlatform, 15 rustc, 16 auditable ? !cargo-auditable.meta.broken, 17 cargo-auditable, 18}: 19 20rustPlatform.buildRustPackage.override 21 { 22 cargo-auditable = cargo-auditable.bootstrap; 23 } 24 { 25 pname = "cargo"; 26 inherit (rustc.unwrapped) version src; 27 28 # the rust source tarball already has all the dependencies vendored, no need to fetch them again 29 cargoVendorDir = "vendor"; 30 buildAndTestSubdir = "src/tools/cargo"; 31 32 inherit auditable; 33 34 passthru = { 35 rustc = rustc; 36 inherit (rustc.unwrapped) tests; 37 }; 38 39 # changes hash of vendor directory otherwise 40 dontUpdateAutotoolsGnuConfigScripts = true; 41 42 nativeBuildInputs = [ 43 pkg-config 44 cmake 45 installShellFiles 46 makeWrapper 47 (lib.getDev pkgsHostHost.curl) 48 zlib 49 ]; 50 buildInputs = [ 51 file 52 curl 53 python3 54 openssl 55 zlib 56 ]; 57 58 env = { 59 # cargo uses git-rs which is made for a version of libgit2 from recent master that 60 # is not compatible with the current version in nixpkgs. 61 #LIBGIT2_SYS_USE_PKG_CONFIG = 1; 62 63 # fixes: the cargo feature `edition` requires a nightly version of Cargo, but this is the `stable` channel 64 RUSTC_BOOTSTRAP = 1; 65 66 } 67 // lib.optionalAttrs (stdenv.hostPlatform.rust.rustcTargetSpec == "x86_64-unknown-linux-gnu") { 68 # Upstream defaults to lld on x86_64-unknown-linux-gnu, we want to use our linker 69 RUSTFLAGS = "-Clinker-features=-lld -Clink-self-contained=-linker"; 70 }; 71 72 postInstall = '' 73 wrapProgram "$out/bin/cargo" --suffix PATH : "${rustc}/bin" 74 75 installManPage src/tools/cargo/src/etc/man/* 76 77 installShellCompletion --bash --name cargo \ 78 src/tools/cargo/src/etc/cargo.bashcomp.sh 79 80 installShellCompletion --zsh src/tools/cargo/src/etc/_cargo 81 ''; 82 83 checkPhase = '' 84 # Disable cross compilation tests 85 export CFG_DISABLE_CROSS_TESTS=1 86 cargo test 87 ''; 88 89 # Disable check phase as there are failures (4 tests fail) 90 doCheck = false; 91 92 doInstallCheck = !stdenv.hostPlatform.isStatic && stdenv.hostPlatform.isElf; 93 installCheckPhase = '' 94 runHook preInstallCheck 95 ${stdenv.cc.targetPrefix}readelf -a $out/bin/.cargo-wrapped | grep -F 'Shared library: [libcurl.so' 96 runHook postInstallCheck 97 ''; 98 99 meta = { 100 homepage = "https://crates.io"; 101 description = "Downloads your Rust project's dependencies and builds your project"; 102 mainProgram = "cargo"; 103 teams = [ lib.teams.rust ]; 104 license = [ 105 lib.licenses.mit 106 lib.licenses.asl20 107 ]; 108 platforms = lib.platforms.unix; 109 # https://github.com/alexcrichton/nghttp2-rs/issues/2 110 broken = stdenv.hostPlatform.isx86 && stdenv.buildPlatform != stdenv.hostPlatform; 111 }; 112 }