rust: update cargo builder to fetch registry dynamically

The biggest benefit is that we no longer have to update the registry
package. This means that just about any cargo package can be built by
nix. No longer does `cargo update` need to be feared because it will
update to packages newer then what is available in nixpkgs.

Instead of fetching the cargo registry this bundles all the source code
into a "vendor/" folder.

This also uses the new --frozen and --locked flags which is nice.

Currently cargo-vendor only provides binaries for Linux and
macOS 64-bit. This can be solved by building it for the other
architectures and uploading it somewhere (like the NixOS cache).

This also has the downside that it requires a change to everyone's deps
hash. And if the old one is used because it was cached it will fail to
build as it will attempt to use the old version. For this reason the
attribute has been renamed to `cargoSha256`.

Authors:
* Kevin Cox <kevincox@kevincox.ca>
* Jörg Thalheim <Mic92@users.noreply.github.com>
* zimbatm <zimbatm@zimbatm.com>
This commit is contained in:
Kevin Cox
2017-08-05 15:38:48 +01:00
committed by zimbatm
parent d170c2cead
commit 5f8cf0048e
47 changed files with 167 additions and 400 deletions

View File

@@ -1,6 +1,6 @@
{ stdenv, fetchFromGitHub, file, curl, pkgconfig, python, openssl, cmake, zlib
, makeWrapper, libiconv, cacert, rustPlatform, rustc, libgit2
, version, srcSha, depsSha256
, version, srcSha, cargoSha256
, patches ? []}:
rustPlatform.buildRustPackage rec {
@@ -14,7 +14,7 @@ rustPlatform.buildRustPackage rec {
sha256 = srcSha;
};
inherit depsSha256;
inherit cargoSha256;
inherit patches;
passthru.rustc = rustc;

View File

@@ -22,7 +22,7 @@ rec {
};
patches = [
./patches/darwin-disable-fragile-tcp-tests.patch
./patches/0001-Disable-fragile-tests-libstd-net-tcp-on-Darwin-Linux.patch
] ++ stdenv.lib.optional stdenv.needsPax ./patches/grsec.patch;
};
@@ -30,7 +30,7 @@ rec {
cargo = callPackage ./cargo.nix rec {
version = "0.21.1";
srcSha = "1nz7sz7rzc6i1c0nzf6kmnmaq1l3hgrg19s589q7k309r6m7p7f7";
depsSha256 = "0pzfn1zjgklr0fw9zi9sxrwr08q3wcvdl9ybxrk3ld7ps5h9wmsi";
cargoSha256 = "02gdh71jkhmr17q5gam079ig5dvpw1fms3v6k5h2bg3fclw7kkrs";
inherit rustc; # the rustc that will be wrapped by cargo
inherit rustPlatform; # used to build cargo

View File

@@ -1,17 +1,18 @@
From 1d8a91d5b09cb762fe890d04bfb61b9eefd0624a Mon Sep 17 00:00:00 2001
From: Moritz Ulrich <moritz@tarn-vedra.de>
Date: Sun, 8 Jan 2017 10:28:17 +0100
Subject: [PATCH] Disable libstd::net::tcp::{ttl, timeouts} on Darwin
From 26d3b70abec1adf773522643b31ce9c03439916a Mon Sep 17 00:00:00 2001
From: Joerg Thalheim <joerg@thalheim.io>
Date: Tue, 10 Oct 2017 00:40:20 +0100
Subject: [PATCH] Disable fragile tests libstd::net::tcp on Darwin/Linux
Signed-off-by: Joerg Thalheim <joerg@thalheim.io>
---
src/libstd/net/tcp.rs | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
src/libstd/net/tcp.rs | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs
index 0e7c5b0671..d42fd26267 100644
index 8d1e7882e5..2c223fb315 100644
--- a/src/libstd/net/tcp.rs
+++ b/src/libstd/net/tcp.rs
@@ -551,6 +551,7 @@ mod tests {
@@ -949,6 +949,7 @@ mod tests {
})
}
@@ -19,7 +20,7 @@ index 0e7c5b0671..d42fd26267 100644
#[test]
fn write_close() {
each_ip(&mut |addr| {
@@ -1022,7 +1023,10 @@ mod tests {
@@ -1421,7 +1422,10 @@ mod tests {
// FIXME: re-enabled bitrig/openbsd tests once their socket timeout code
// no longer has rounding errors.
@@ -31,7 +32,7 @@ index 0e7c5b0671..d42fd26267 100644
#[test]
fn timeouts() {
let addr = next_test_ip4();
@@ -1101,6 +1105,7 @@ mod tests {
@@ -1500,6 +1504,7 @@ mod tests {
assert_eq!(false, t!(stream.nodelay()));
}
@@ -39,6 +40,14 @@ index 0e7c5b0671..d42fd26267 100644
#[test]
fn ttl() {
let ttl = 100;
@@ -1568,6 +1573,7 @@ mod tests {
})
}
+ #[cfg_attr(target_os = "linux", ignore)]
#[test]
fn connect_timeout_unroutable() {
// this IP is unroutable, so connections should always time out,
--
2.11.0
2.14.2