rust: Refactoring of rust and cargo packages

This commit is contained in:
David Craven
2016-06-14 12:49:48 +02:00
parent d8a7aaf179
commit 54f80775cb
27 changed files with 181 additions and 198 deletions

View File

@@ -1,50 +0,0 @@
{ stdenv, fetchurl, makeWrapper, cacert, zlib, rustc }:
let
platform =
if stdenv.system == "i686-linux"
then "i686-unknown-linux-gnu"
else if stdenv.system == "x86_64-linux"
then "x86_64-unknown-linux-gnu"
else if stdenv.system == "i686-darwin"
then "i686-apple-darwin"
else if stdenv.system == "x86_64-darwin"
then "x86_64-apple-darwin"
else abort "missing boostrap url for platform ${stdenv.system}";
# fetch hashes by running `print-hashes.sh 1.9.0`
bootstrapHash =
if stdenv.system == "i686-linux"
then "dd4d9bf1b9393867eb18d00431e8fb733894984f2c7b5154bc1b64d045077b45"
else if stdenv.system == "x86_64-linux"
then "288ff13efa2577e81c77fc2cb6e2b49b1ed0ceab51b4fa12f7efb87039ac49b7"
else if stdenv.system == "i686-darwin"
then "4d4d4b256d6bd6ae2527cf61007b2553de200f0a1910b7ad41e4f51d2b21e536"
else if stdenv.system == "x86_64-darwin"
then "d59b5509e69c1cace20a57072e3b3ecefdbfd8c7e95657b0ff2ac10aa1dfebe6"
else throw "missing boostrap hash for platform ${stdenv.system}";
in
stdenv.mkDerivation rec {
name = "cargo-bootstrap-${version}";
version = "1.9.0";
src = fetchurl {
url = "https://static.rust-lang.org/dist/rust-${version}-${platform}.tar.gz";
sha256 = bootstrapHash;
};
passthru.rustc = rustc;
buildInputs = [makeWrapper zlib];
phases = ["unpackPhase" "installPhase"];
installPhase = ''
cp -r cargo "$out"
patchelf \
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
"$out/bin/cargo"
wrapProgram "$out/bin/cargo" \
--suffix PATH : "${rustc}/bin"
'';
}

View File

@@ -1,14 +0,0 @@
{ stdenv, callPackage, rustc, makeRustPlatform, recurseIntoAttrs }:
let
cargoBootstrap = callPackage ./bootstrap.nix {};
rustPlatformBootstrap = recurseIntoAttrs (makeRustPlatform cargoBootstrap rustPlatformBootstrap);
in
callPackage ./generic.nix rec {
version = "0.10.0";
srcRev = "refs/tags/${version}";
srcSha = "06scvx5qh60mgvlpvri9ig4np2fsnicsfd452fi9w983dkxnz4l2";
depsSha256 = "0js4697n7v93wnqnpvamhp446w58llj66za5hkd6wannmc0gsy3b";
inherit rustc;
rustPlatform = rustPlatformBootstrap;
}

View File

@@ -1,64 +0,0 @@
{ stdenv, fetchgit, file, curl, pkgconfig, python, openssl, cmake, zlib
, makeWrapper, libiconv, cacert, rustPlatform, rustc
, version, srcRev, srcSha, depsSha256 }:
rustPlatform.buildRustPackage rec {
name = "cargo-${version}";
inherit version;
src = fetchgit {
url = "https://github.com/rust-lang/cargo";
rev = srcRev;
sha256 = srcSha;
};
inherit depsSha256;
passthru.rustc = rustc;
buildInputs = [ file curl pkgconfig python openssl cmake zlib makeWrapper ]
++ stdenv.lib.optional stdenv.isDarwin libiconv;
configurePhase = ''
./configure --enable-optimize --prefix=$out --local-cargo=${rustPlatform.cargo}/bin/cargo
'';
buildPhase = "make";
installPhase = ''
make install
${postInstall}
'';
postInstall = ''
rm "$out/lib/rustlib/components" \
"$out/lib/rustlib/install.log" \
"$out/lib/rustlib/rust-installer-version" \
"$out/lib/rustlib/uninstall.sh" \
"$out/lib/rustlib/manifest-cargo"
wrapProgram "$out/bin/cargo" \
--suffix PATH : "${rustc}/bin" \
--run "export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt" \
${stdenv.lib.optionalString stdenv.isDarwin ''--suffix DYLD_LIBRARY_PATH : "${rustc}/lib"''}
'';
checkPhase = ''
# Export SSL_CERT_FILE as without it one test fails with SSL verification error
export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
# Disable cross compilation tests
export CFG_DISABLE_CROSS_TESTS=1
cargo test
'';
# Disable check phase as there are failures (author_prefers_cargo test fails)
doCheck = false;
meta = with stdenv.lib; {
homepage = http://crates.io;
description = "Downloads your Rust project's dependencies and builds your project";
maintainers = with maintainers; [ wizeman retrry ];
license = [ licenses.mit licenses.asl20 ];
platforms = platforms.linux ++ platforms.darwin;
};
}

View File

@@ -1,10 +0,0 @@
{ stdenv, callPackage, rustc, rustPlatform }:
callPackage ./generic.nix rec {
version = "2016.06.07";
srcRev = "3e70312a2a4ebedace131fc63bb8f27463c5db28";
srcSha = "0nibzyfjkiqfnq0c00hhqvs856l5qls8wds252p97q5q92yvp40f";
depsSha256 = "1xbb33aqnf5yyws6gjys9w8kznbh9rh6hw8mpg1hhq1ahipc2j1f";
inherit rustc;
inherit rustPlatform;
}

View File

@@ -1,17 +0,0 @@
#!/bin/sh
PLATFORMS="i686-unknown-linux-gnu x86_64-unknown-linux-gnu i686-apple-darwin x86_64-apple-darwin"
BASEURL="https://static.rust-lang.org/dist"
VERSION=$1
if [[ -z $VERSION ]]
then
echo "No version supplied"
exit -1
fi
for PLATFORM in $PLATFORMS
do
URL="$BASEURL/rust-$VERSION-$PLATFORM.tar.gz.sha256"
curl $URL
done

View File

@@ -17,13 +17,13 @@ buildRustPackage rec {
buildInputs = [ makeWrapper ];
preCheck = ''
export RUST_SRC;_PATH="${rustc.src}/src"
export RUST_SRC;_PATH="${rustPlatform.rust.rustc.src}/src"
'';
installPhase = ''
mkdir -p $out/bin
cp -p target/release/racer $out/bin/
wrapProgram $out/bin/racer --set RUST_SRC_PATH "${rustc.src}/src"
wrapProgram $out/bin/racer --set RUST_SRC_PATH "${rustPlatform.rust.rustc.src}/src"
'';
meta = with stdenv.lib; {

View File

@@ -17,7 +17,7 @@ buildRustPackage rec {
buildInputs = [ makeWrapper ];
RUST_SRC_PATH = ''${rustc.src}/src'';
RUST_SRC_PATH = ''${rustPlatform.rust.rustc.src}/src'';
installPhase = ''
mkdir -p $out/bin