Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at release-18.03 65 lines 2.3 kB view raw
1{ stdenv, fetchFromGitHub, file, curl, pkgconfig, python, openssl, cmake, zlib 2, makeWrapper, libiconv, cacert, rustPlatform, rustc, libgit2, darwin 3, version 4, patches ? [] 5, src }: 6 7let 8 inherit (darwin.apple_sdk.frameworks) CoreFoundation; 9in 10 11rustPlatform.buildRustPackage rec { 12 name = "cargo-${version}"; 13 inherit version src patches; 14 15 # the rust source tarball already has all the dependencies vendored, no need to fetch them again 16 cargoVendorDir = "src/vendor"; 17 preBuild = "cd src; pushd tools/cargo"; 18 postBuild = "popd"; 19 20 passthru.rustc = rustc; 21 22 # changes hash of vendor directory otherwise on aarch64 23 dontUpdateAutotoolsGnuConfigScripts = if stdenv.isAarch64 then "1" else null; 24 25 nativeBuildInputs = [ pkgconfig ]; 26 buildInputs = [ cacert file curl python openssl cmake zlib makeWrapper libgit2 ] 27 ++ stdenv.lib.optionals stdenv.isDarwin [ CoreFoundation libiconv ]; 28 29 LIBGIT2_SYS_USE_PKG_CONFIG=1; 30 31 # FIXME: Use impure version of CoreFoundation because of missing symbols. 32 # CFURLSetResourcePropertyForKey is defined in the headers but there's no 33 # corresponding implementation in the sources from opensource.apple.com. 34 preConfigure = stdenv.lib.optionalString stdenv.isDarwin '' 35 export NIX_CFLAGS_COMPILE="-F${CoreFoundation}/Library/Frameworks $NIX_CFLAGS_COMPILE" 36 ''; 37 38 postInstall = '' 39 # NOTE: We override the `http.cainfo` option usually specified in 40 # `.cargo/config`. This is an issue when users want to specify 41 # their own certificate chain as environment variables take 42 # precedence 43 wrapProgram "$out/bin/cargo" \ 44 --suffix PATH : "${rustc}/bin" \ 45 --set CARGO_HTTP_CAINFO "${cacert}/etc/ssl/certs/ca-bundle.crt" \ 46 --set SSL_CERT_FILE "${cacert}/etc/ssl/certs/ca-bundle.crt" 47 ''; 48 49 checkPhase = '' 50 # Disable cross compilation tests 51 export CFG_DISABLE_CROSS_TESTS=1 52 cargo test 53 ''; 54 55 # Disable check phase as there are failures (4 tests fail) 56 doCheck = false; 57 58 meta = with stdenv.lib; { 59 homepage = https://crates.io; 60 description = "Downloads your Rust project's dependencies and builds your project"; 61 maintainers = with maintainers; [ wizeman retrry ]; 62 license = [ licenses.mit licenses.asl20 ]; 63 platforms = platforms.unix; 64 }; 65}