Skip to content

Commit

Permalink
cargo: Use stable releases instead of snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
dvc94ch committed Jun 14, 2016
1 parent 0602759 commit 0720373
Show file tree
Hide file tree
Showing 10 changed files with 164 additions and 206 deletions.
@@ -1,13 +1,15 @@
{ stdenv, callPackage }:
{ stdenv, callPackage, targets ? [], targetToolchains ? [] }:

callPackage ./generic.nix {
shortVersion = "1.9.0";
isRelease = true;
forceBundledLLVM = false;
configureFlags = [ "--release-channel=stable" ];
srcRev = "e4e8b666850a763fdf1c3c2c142856ab51e32779";
srcSha = "1pz4qx70mqv78fxm4w1mq7csk5pssq4qmr2vwwb5v8hyx03caff8";
srcSha = "167rh7hs77grn895h54s7np7f0k7b6i8z4wdfinncg4chy08hxq1";
patches = [ ./patches/remove-uneeded-git.patch ]
++ stdenv.lib.optional stdenv.needsPax ./patches/grsec.patch;
rustc = callPackage ./bootstrap.nix {};
rustc = callPackage ./snapshot.nix {};
inherit targets;
inherit targetToolchains;
}
6 changes: 3 additions & 3 deletions pkgs/development/compilers/rustc/generic.nix
@@ -1,5 +1,5 @@
{ stdenv, fetchurl, fetchgit, fetchzip, file, python2, tzdata, procps
, llvm, jemalloc, ncurses, darwin, binutils, rustc
, llvm, jemalloc, ncurses, darwin, binutils, rustc, git

, isRelease ? false
, shortVersion
Expand Down Expand Up @@ -112,8 +112,8 @@ stdenv.mkDerivation {
'';

# ps is needed for one of the test cases
nativeBuildInputs = [ file python2 procps rustc ];
buildInputs = [ ncurses ]
nativeBuildInputs = [ file python2 procps rustc git ];
buildInputs = [ ncurses ] ++ targetToolchains
++ stdenv.lib.optional (!forceBundledLLVM) llvmShared;

# https://github.com/rust-lang/rust/issues/30181
Expand Down
50 changes: 50 additions & 0 deletions pkgs/development/tools/build-managers/cargo/bootstrap.nix
@@ -0,0 +1,50 @@
{ 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"
'';
}
38 changes: 0 additions & 38 deletions pkgs/development/tools/build-managers/cargo/common.nix

This file was deleted.

55 changes: 10 additions & 45 deletions pkgs/development/tools/build-managers/cargo/default.nix
@@ -1,49 +1,14 @@
{ stdenv, lib, cacert, fetchgit, rustPlatform, file, curl, python, pkgconfig, openssl
, cmake, zlib, makeWrapper
# Darwin dependencies
, libiconv }:
{ stdenv, callPackage, rustc, makeRustPlatform, recurseIntoAttrs }:

with rustPlatform;

with ((import ./common.nix) {
inherit stdenv rustc;
let
cargoBootstrap = callPackage ./bootstrap.nix {};
rustPlatformBootstrap = recurseIntoAttrs (makeRustPlatform cargoBootstrap rustPlatformBootstrap);
in
callPackage ./generic.nix rec {
version = "0.10.0";
});

buildRustPackage rec {
inherit name version meta passthru;

# Needs to use fetchgit instead of fetchFromGitHub to fetch submodules
src = fetchgit {
url = "git://github.com/rust-lang/cargo";
rev = "refs/tags/${version}";
sha256 = "06scvx5qh60mgvlpvri9ig4np2fsnicsfd452fi9w983dkxnz4l2";
};

srcRev = "refs/tags/${version}";
srcSha = "06scvx5qh60mgvlpvri9ig4np2fsnicsfd452fi9w983dkxnz4l2";
depsSha256 = "0js4697n7v93wnqnpvamhp446w58llj66za5hkd6wannmc0gsy3b";

buildInputs = [ file curl pkgconfig python openssl cmake zlib makeWrapper ]
++ lib.optional stdenv.isDarwin libiconv;

configurePhase = ''
./configure --enable-optimize --prefix=$out --local-cargo=${cargo}/bin/cargo
'';

buildPhase = "make";

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;

installPhase = ''
make install
${postInstall}
'';
inherit rustc;
rustPlatform = rustPlatformBootstrap;
}
64 changes: 64 additions & 0 deletions pkgs/development/tools/build-managers/cargo/generic.nix
@@ -0,0 +1,64 @@
{ 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;
};
}
43 changes: 7 additions & 36 deletions pkgs/development/tools/build-managers/cargo/head.nix
@@ -1,39 +1,10 @@
{ stdenv, fetchgit, rustPlatform, file, curl, python, pkgconfig, openssl
, cmake, zlib, makeWrapper }:

with rustPlatform;

with ((import ./common.nix) {
inherit stdenv rustc;
version = "2016-03-20";
});

buildRustPackage rec {
inherit name version meta passthru;

# Needs to use fetchgit instead of fetchFromGitHub to fetch submodules
src = fetchgit {
url = "git://github.com/rust-lang/cargo";
rev = "7d79da08238e3d47e0bc4406155bdcc45ccb8c82";
sha256 = "190qdii53s4vk940yzs2iizhfs22y2v8bzw051bl6bk9bs3y4fdd";
};
{ stdenv, callPackage, rustc, rustPlatform }:

callPackage ./generic.nix rec {
version = "2016.06.07";
srcRev = "3e70312a2a4ebedace131fc63bb8f27463c5db28";
srcSha = "0nibzyfjkiqfnq0c00hhqvs856l5qls8wds252p97q5q92yvp40f";
depsSha256 = "1xbb33aqnf5yyws6gjys9w8kznbh9rh6hw8mpg1hhq1ahipc2j1f";

buildInputs = [ file curl pkgconfig python openssl cmake zlib makeWrapper ];

configurePhase = ''
./configure --enable-optimize --prefix=$out --local-cargo=${cargo}/bin/cargo
'';

buildPhase = "make";

# Disable check phase as there are lots of failures (some probably due to
# trying to access the network).
doCheck = false;

installPhase = ''
make install
${postInstall}
'';
inherit rustc;
inherit rustPlatform;
}
17 changes: 17 additions & 0 deletions pkgs/development/tools/build-managers/cargo/print-hashes.sh
@@ -0,0 +1,17 @@
#!/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
55 changes: 0 additions & 55 deletions pkgs/development/tools/build-managers/cargo/snapshot.nix

This file was deleted.

0 comments on commit 0720373

Please sign in to comment.