nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at 22.05 76 lines 2.6 kB view raw
1{ lib, stdenv, pkgsHostHost 2, file, curl, pkg-config, python3, openssl, cmake, zlib 3, installShellFiles, makeWrapper, cacert, rustPlatform, rustc 4, CoreFoundation, Security 5}: 6 7rustPlatform.buildRustPackage { 8 pname = "cargo"; 9 inherit (rustc) version src; 10 11 # the rust source tarball already has all the dependencies vendored, no need to fetch them again 12 cargoVendorDir = "vendor"; 13 buildAndTestSubdir = "src/tools/cargo"; 14 15 passthru.rustc = rustc; 16 17 # changes hash of vendor directory otherwise 18 dontUpdateAutotoolsGnuConfigScripts = true; 19 20 nativeBuildInputs = [ 21 pkg-config cmake installShellFiles makeWrapper 22 (lib.getDev pkgsHostHost.curl) 23 ]; 24 buildInputs = [ cacert file curl python3 openssl zlib ] 25 ++ lib.optionals stdenv.isDarwin [ CoreFoundation Security ]; 26 27 # cargo uses git-rs which is made for a version of libgit2 from recent master that 28 # is not compatible with the current version in nixpkgs. 29 #LIBGIT2_SYS_USE_PKG_CONFIG = 1; 30 31 # fixes: the cargo feature `edition` requires a nightly version of Cargo, but this is the `stable` channel 32 RUSTC_BOOTSTRAP = 1; 33 34 postInstall = '' 35 # NOTE: We override the `http.cainfo` option usually specified in 36 # `.cargo/config`. This is an issue when users want to specify 37 # their own certificate chain as environment variables take 38 # precedence 39 wrapProgram "$out/bin/cargo" \ 40 --suffix PATH : "${rustc}/bin" \ 41 --set CARGO_HTTP_CAINFO "${cacert}/etc/ssl/certs/ca-bundle.crt" \ 42 --set SSL_CERT_FILE "${cacert}/etc/ssl/certs/ca-bundle.crt" 43 44 installManPage src/tools/cargo/src/etc/man/* 45 46 installShellCompletion --bash --name cargo \ 47 src/tools/cargo/src/etc/cargo.bashcomp.sh 48 49 installShellCompletion --zsh src/tools/cargo/src/etc/_cargo 50 ''; 51 52 checkPhase = '' 53 # Disable cross compilation tests 54 export CFG_DISABLE_CROSS_TESTS=1 55 cargo test 56 ''; 57 58 # Disable check phase as there are failures (4 tests fail) 59 doCheck = false; 60 61 doInstallCheck = !stdenv.hostPlatform.isStatic && 62 stdenv.hostPlatform.parsed.kernel.execFormat == lib.systems.parse.execFormats.elf; 63 installCheckPhase = '' 64 runHook preInstallCheck 65 readelf -a $out/bin/.cargo-wrapped | grep -F 'Shared library: [libcurl.so' 66 runHook postInstallCheck 67 ''; 68 69 meta = with lib; { 70 homepage = "https://crates.io"; 71 description = "Downloads your Rust project's dependencies and builds your project"; 72 maintainers = with maintainers; [ retrry ]; 73 license = [ licenses.mit licenses.asl20 ]; 74 platforms = platforms.unix; 75 }; 76}