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

@ -9,16 +9,15 @@ date: 2017-03-05
To install the rust compiler and cargo put
```
rustStable.rustc
rustStable.cargo
rust
```
into the `environment.systemPackages` or bring them into scope with
`nix-shell -p rustStable.rustc -p rustStable.cargo`.
into the `environment.systemPackages` or bring them into
scope with `nix-shell -p rust`.
There are also `rustBeta` and `rustNightly` package sets available.
These are not updated very regularly. For daily builds use either rustup from
nixpkgs or use the [Rust nightlies overlay](#using-the-rust-nightlies-overlay).
For daily builds (beta and nightly) use either rustup from
nixpkgs or use the [Rust nightlies
overlay](#using-the-rust-nightlies-overlay).
## Packaging Rust applications
@ -38,7 +37,7 @@ buildRustPackage rec {
sha256 = "0y5d1n6hkw85jb3rblcxqas2fp82h3nghssa4xqrhqnz25l799pj";
};
depsSha256 = "0q68qyl2h6i0qsz82z840myxlnjay8p1w5z7hfyr8fqp7wgwa9cx";
cargoSha256 = "0q68qyl2h6i0qsz82z840myxlnjay8p1w5z7hfyr8fqp7wgwa9cx";
meta = with stdenv.lib; {
description = "A utility that combines the usability of The Silver Searcher with the raw speed of grep";
@ -50,7 +49,7 @@ buildRustPackage rec {
}
```
`buildRustPackage` requires a `depsSha256` attribute which is computed over
`buildRustPackage` requires a `cargoSha256` attribute which is computed over
all crate sources of this package. Currently it is obtained by inserting a
fake checksum into the expression and building the package once. The correct
checksum can be then take from the failed build.
@ -76,11 +75,11 @@ in the `~/.config/nixpkgs/overlays` directory.
The latest version can be installed with the following command:
$ nix-env -Ai nixos.rustChannels.stable.rust
$ nix-env -Ai nixos.latest.rustChannels.stable.rust
Or using the attribute with nix-shell:
$ nix-shell -p nixos.rustChannels.stable.rust
$ nix-shell -p nixos.latest.rustChannels.stable.rust
To install the beta or nightly channel, "stable" should be substituted by
"nightly" or "beta", or

View file

@ -13,7 +13,7 @@ buildRustPackage rec {
sha256 = "1rg7ydvnhlg8w6blilm3cv6v4q51x1hgrbkln2ikhpdq0vakp5fd";
};
depsSha256 = "1n4rxipna307r4xppb2iaads7kpa3yjv99fimvpn8l0f999ir2rz";
cargoSha256 = "0i9617qwc6d4jvlbydwk03rcsnyvxzpbn2ms10ds4r6x7jy2a4sy";
cargoBuildFlags = ["--features cli"];

View file

@ -13,12 +13,13 @@ buildRustPackage rec {
sha256 = "1w651g4p2mc4ljp20l8lwvfx3l3fzyp6gf2izr85vyb1wjbaccqn";
};
depsSha256 = "14x8pbjgkz0g724lnvd9mi2alqd6fipjljw6xsraf9gqwijn1knq";
cargoSha256 = "14x8pbjgkz0g724lnvd9mi2alqd6fipjljw6xsraf9gqwijn1kn0";
meta = {
description = "Directly run Ethereum bytecode";
homepage = https://github.com/dapphub/ethrun/;
maintainers = [stdenv.lib.maintainers.dbrock];
broken = true; # mark temporary as broken
inherit version;
};
}

View file

@ -11,7 +11,7 @@ rustPlatform.buildRustPackage rec {
sha256 = "02l1f46frpvw1r6k1wfh77mrsnmsdvifqx0vnscxz4xgb9ia9d1c";
};
depsSha256 = "02qx8zdhmj7rmhqqq5q9428x9mlrjxxcnn4yhnygz9gfgvada2hx";
cargoSha256 = "1b0kal53ggcr59hbrsdj8fifjycahrmzwq677n9h3fywv4r237m6";
installPhase = ''
mkdir -p $out/lib

View file

@ -38,7 +38,7 @@ buildRustPackage rec {
sha256 = "0h37x12r33xwz9vf1n8y24c0ph5w17lhkpfi5q6lbpgidvbs6fyx";
};
depsSha256 = "05gkl2zg546i2pm0gx11s56f7dk72qpm39kml1d2myj81s0vyb5z";
cargoSha256 = "0w3j92kd27pny37pfvlv6qsnbb1lgphmfbhvvng0z96r2b1wjviz";
buildInputs = [
cmake
@ -69,6 +69,7 @@ buildRustPackage rec {
dontPatchELF = true;
meta = with stdenv.lib; {
broken = true;
description = "GPU-accelerated terminal emulator";
homepage = https://github.com/jwilm/alacritty;
license = with licenses; [ asl20 ];

View file

@ -14,7 +14,7 @@ buildRustPackage rec {
sha256 = "0pqrm85pd9hqn5fwqjbyyrrfh4k7q9mi9qy9hm8yigk5l8mw44y1";
};
depsSha256 = "1ahfm5agvabqqqgjsyjb95xxbc7mng1mdyclcakwp1m1qdkxx9py";
cargoSha256 = "1ahfm5agvabqqqgjsyjb95xxbc7mng1mdyclcakwp1m1qdkxx9p0";
buildInputs = [ libsodium libarchive openssl ];
@ -35,5 +35,6 @@ buildRustPackage rec {
license = licenses.asl20;
maintainers = [ maintainers.rushmorem ];
platforms = [ "x86_64-linux" "x86_64-darwin" ];
broken = true; # mark temporary as broken due git dependencies
};
}

View file

@ -12,7 +12,7 @@ buildRustPackage rec {
sha256 = "1mcdjykrgh0jq6k6y664lai8sbgzk6j7k0r944f43vg63d1jql5b";
};
depsSha256 = "0whs3fgmpb6g1mjajs3qs9g613x5dal4x6ghzzkpl73a9pgydkpn";
cargoSha256 = "0k9d6pxsb4gvkqs00g71c1nnz773iccg4vajgn33qdym6m6qsjwy";
buildInputs = [ makeWrapper openssl ];

View file

@ -23,7 +23,7 @@ buildRustPackage rec {
sha256 = "1sx6sc2dj3l61gbiqz8vfyhw5w4xjdyfzn1ixz0y8ipm579yc7a2";
};
depsSha256 = "1z2n3z5wkh5z5vc976yscq77fgjszwzwlrp7g17hmsbhzx6x170h";
cargoSha256 = "08zbvjwjdpv2sbj6mh73py82inhs18jvmh8m9k4l94fcz6ykgqwr";
nativeBuildInputs = [
cmake

View file

@ -18,7 +18,7 @@ buildRustPackage rec {
doCheck = false;
depsSha256 = "1qzzpnkyw1bn5fnj06c80f7985v1q0rqcphrrrkpbi33lg5mzgbv";
cargoSha256 = "0r69vghjd6b30v0qjsipyv56n92iwvyxmllrnwjzjf5pzhhjl7sy";
meta = with stdenv.lib; {
description = "A distributed version control system";

View file

@ -14,13 +14,14 @@ buildRustPackage rec {
sha256 = "10s01x54kwjm2c85v57i6g3pvj5w3wpkjblj036mmd865fla1brb";
};
depsSha256 = "1k5xbw2zhm5z650mxdbxixr90im53wlpjdvq2pbnx2snqm84idlc";
cargoSha256 = "06qivlybmmc49ksv4232sm1r4hp923xsq4c2ksa4i2azdzc1csdc";
buildInputs = [ wlc dbus_libs dbus_glib cairo libxkbcommon ];
nativeBuildInputs = [ pkgconfig ];
meta = with stdenv.lib; {
broken = true;
description = "Customizable Wayland compositor (window manager)";
longDescription = ''
Way Cooler is a customizable tiling window manager written in Rust

View file

@ -9,7 +9,7 @@ rustPlatform.buildRustPackage rec {
sha256 = "1r74nhcwiy2rmifzjhdal3jcqz4jz48nfvhdyw4gasa6nxp3msdl";
};
depsSha256 = "0z7h8ybh2db3xl8qxbzby5lncdaijixzmbn1j8a45lbky1xiix71";
cargoSha256 = "0z92ml84b5652zgwzn08a8vvxksaa54jql66sfpdz1mvjwhgdmvn";
nativeBuildInputs = [ pkgconfig ];
buildInputs = [ libXinerama libX11 ];
@ -31,6 +31,7 @@ rustPlatform.buildRustPackage rec {
'';
meta = with stdenv.lib; {
broken = true;
description = "A tiling window manager in Rust";
homepage = https://github.com/Kintaro/wtftw;
license = stdenv.lib.licenses.bsd3;

View file

@ -0,0 +1,32 @@
{ fetchurl, stdenv }:
let
inherit (stdenv) system;
version = "0.1.12";
hashes = {
x86_64-linux = "1hxlavcxy374yypfamlkygjg662lhll8j434qcvdawkvlidg5ii5";
x86_64-darwin = "1jkvhh710gwjnnjx59kaplx2ncfvkx9agfa76rr94sbjqq4igddm";
};
hash = hashes. ${system} or (throw "missing bootstrap hash for platform ${system}");
platforms = {
x86_64-linux = "x86_64-unknown-linux-musl";
x86_64-darwin = "x86_64-apple-darwin";
};
platform = platforms . ${system};
in stdenv.mkDerivation {
name = "cargo-vendor-${version}";
src = fetchurl {
url = "https://github.com/alexcrichton/cargo-vendor/releases/download/${version}/cargo-vendor-${version}-${platform}.tar.gz";
sha256 = hash;
};
phases = "unpackPhase installPhase";
installPhase = ''
install -Dm755 cargo-vendor $out/bin/cargo-vendor
'';
}

View file

@ -1,10 +1,14 @@
{ stdenv, callPackage, path, cacert, git, rust, rustRegistry }:
{ fetchurl, stdenv, path, cacert, git, rust }:
let
rustRegistry' = rustRegistry;
cargoVendor = import ./cargo-vendor.nix {
inherit fetchurl stdenv;
};
fetchcargo = import ./fetchcargo.nix {
inherit stdenv cacert git rust cargoVendor;
};
in
{ name, depsSha256
, rustRegistry ? rustRegistry'
{ name, cargoSha256
, src ? null
, srcs ? null
, sourceRoot ? null
@ -18,17 +22,13 @@ in
let
lib = stdenv.lib;
fetchDeps = import ./fetchcargo.nix {
inherit stdenv cacert git rust rustRegistry;
};
cargoDeps = fetchDeps {
cargoDeps = fetchcargo {
inherit name src srcs sourceRoot cargoUpdateHook;
sha256 = depsSha256;
sha256 = cargoSha256;
};
in stdenv.mkDerivation (args // {
inherit cargoDeps rustRegistry;
inherit cargoDeps;
patchRegistryDeps = ./patch-registry-deps;
@ -43,71 +43,24 @@ in stdenv.mkDerivation (args // {
postUnpack = ''
eval "$cargoDepsHook"
echo "Using cargo deps from $cargoDeps"
mkdir .cargo
cat >.cargo/config <<-EOF
[source.crates-io]
registry = 'https://github.com/rust-lang/crates.io-index'
replace-with = 'vendored-sources'
cp -a "$cargoDeps" deps
chmod +w deps -R
# It's OK to use /dev/null as the URL because by the time we do this, cargo
# won't attempt to update the registry anymore, so the URL is more or less
# irrelevant
cat <<EOF > deps/config
[registry]
index = "file:///dev/null"
[source.vendored-sources]
directory = '$cargoDeps'
EOF
export CARGO_HOME="$(realpath deps)"
export RUST_LOG=${logLevel}
export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
# Let's find out which $indexHash cargo uses for file:///dev/null
(cd $sourceRoot && cargo fetch &>/dev/null) || true
cd deps
indexHash="$(basename $(echo registry/index/*))"
echo "Using indexHash '$indexHash'"
rm -rf -- "registry/cache/$indexHash" \
"registry/index/$indexHash"
mv registry/cache/HASH "registry/cache/$indexHash"
echo "Using rust registry from $rustRegistry"
ln -s "$rustRegistry" "registry/index/$indexHash"
# Retrieved the Cargo.lock file which we saved during the fetch
cd ..
mv deps/Cargo.lock $sourceRoot/
(
cd $sourceRoot
cargo fetch
cargo clean
)
'' + (args.postUnpack or "");
prePatch = ''
# Patch registry dependencies, using the scripts in $patchRegistryDeps
(
set -euo pipefail
cd $NIX_BUILD_TOP/deps/registry/src/*
for script in $patchRegistryDeps/*; do
# Run in a subshell so that directory changes and shell options don't
# affect any following commands
( . $script)
done
)
'' + (args.prePatch or "");
buildPhase = with builtins; args.buildPhase or ''
runHook preBuild
echo "Running cargo build --release ${concatStringsSep " " cargoBuildFlags}"
cargo build --release ${concatStringsSep " " cargoBuildFlags}
cargo build --release --frozen ${concatStringsSep " " cargoBuildFlags}
runHook postBuild
'';
@ -126,4 +79,6 @@ in stdenv.mkDerivation (args // {
find target/release -maxdepth 1 -executable -exec cp "{}" $out/bin \;
runHook postInstall
'';
passthru = { inherit cargoDeps; };
})

View file

@ -1,209 +0,0 @@
# copied from libgit2 source code 'repo-template.h'
makeGitTemplate() {
local target="$1"
mkdir -p -m777 "$target/info" "$target/pack" "$target/objects" "$target/refs"
mkdir -p -m777 "$target/refs/heads" "$target/refs/tags" "$target/objects/info" "$target/objects/pack"
cat <<'EOF' > "$target/description"
Unnamed repository; edit this file 'description' to name the repository.
EOF
chmod 666 "$target/description"
cat <<'EOF' > "$target/info/exclude"
# File patterns to ignore; see `git help ignore` for more information.
# Lines that start with '#' are comments.
EOF
}
fetchCargoDeps() {
src=$(realpath $1)
out=$(realpath $2)
echo "Fetching $src to $out"
mkdir $out
# Configure git template dir to make libgit2 more deterministic
#
# Without a template dir, libgit2 defaults to /usr/share/git-core/templates,
# which can vary between systems if sandboxed builds aren't used.
#
# Note: we explictly set --tmpdir for mktemp here to make it more friendly
# for nix-shell users, where $TMPDIR is not necessarily set to NIX_BUILD_TOP
echo "Setting up git templatedir"
export GIT_TEMPLATE_DIR="$(mktemp -d --tmpdir=$NIX_BUILD_TOP git-template.XXX)"
makeGitTemplate "$GIT_TEMPLATE_DIR"
export XDG_CONFIG_HOME="$(mktemp -d --tmpdir=$NIX_BUILD_TOP home.XXX)"
mkdir -p $XDG_CONFIG_HOME/git
cat <<EOF > $XDG_CONFIG_HOME/git/config
[init]
templatedir = $GIT_TEMPLATE_DIR
EOF
# Configure cargo to fetch from a local copy of the crates.io registry
echo "Using rust registry from $rustRegistry"
cat <<EOF > $out/config
[registry]
index = "file://$rustRegistry"
EOF
export CARGO_HOME=$out
cd $src
if [[ ! -f Cargo.lock ]]; then
echo
echo "ERROR: The Cargo.lock file doesn't exist"
echo
echo "Cargo.lock is needed to make sure that depsSha256 doesn't change"
echo "when the registry is updated."
echo
exit 1
fi
# We need to do the following string replacement so that 'cargo fetch'
# doesn't ignore the versions specified in Cargo.lock
substituteInPlace Cargo.lock \
--replace "registry+https://github.com/rust-lang/crates.io-index" \
"registry+file://$rustRegistry"
# Do any possible 'cargo update -p <pkgName> --precise <version>' ad-hoc updates
eval "$cargoUpdateHook"
# Do the fetch
cargo fetch --verbose
# Now that we have fetched everything, let's make the output deterministic
# Cargo uses the following directory structure for fetched data, where
# $indexHash is a hash of the registry index URL:
#
#
# /config:
#
# Cargo config file. We'll delete this because it's not deterministic,
# and instead recreate it just before running 'cargo build'.
#
# /registry/cache/$indexHash/:
#
# This is where tarballs of registry package dependencies are kept
# We'll need to keep this, but make sure $indexHash is a fixed name.
#
# /registry/index/$indexHash/:
#
# A copy of the registry index is kept here. We can delete this, and
# instead, just before running 'cargo build', we'll symlink this
# directory to our static copy of the registry in the Nix store.
#
# /registry/src/$indexHash/{pkgName-pkgVersion}/:
#
# Here cargo keeps extracted sources of the cached tarballs.
# We'll just delete this because cargo will re-populate them from the
# tarballs.
#
# /git/db/{domain-hash}/:
#
# Here cargo keeps the `.git` directories of git dependencies.
# We'll need to keep these, but make them deterministic.
#
# /git/checkouts/{domain-hash}/{branchName}/:
#
# Here cargo keeps checked-out sources of the git dependencies.
# We can delete this, because cargo will re-populate them from the above
# `.git` directories.
#
# Let's start
# Remove cargo config file, which points to the ever-changing registry
rm $out/config
# Save the Cargo.lock file into the output, so that we don't have to do another
# 'cargo update' during the build (which would try to access the network) for
# any ad-hoc package updates (through $cargoUpdateHook).
#
# We need to replace the rustRegistry URL with something deterministic.
# Since the URL won't actually be accessed anymore, it's fine to use /dev/null.
substituteInPlace Cargo.lock \
--replace "registry+file://$rustRegistry" \
"registry+file:///dev/null"
mv Cargo.lock $out/
# Let's replace $indexHash with something more deterministic
mv $out/registry/cache/* $out/registry/cache/HASH
# The registry index changes all the time, so it's not deterministic
# We'll symlink it before running 'cargo build'
rm -rf $out/registry/index/*
# Make git DBs deterministic
# TODO: test with git submodules
[[ ! -d $out/git/checkouts ]] || (cd $out/git/checkouts && for name in *; do
revs=""
cd "$out/git/checkouts/$name"
while read dir; do
# extract substring: [dir = "./xxx/yyy/.git"] => [branch = "xxx/yyy"]
branch="${dir:2:$((${#dir}-7))}"
cd "$out/git/checkouts/$name/$branch"
rev="$(git rev-parse HEAD)"
revs="$rev $revs"
done < <(find . -type d -name .git -print)
echo "List of revs to keep for git db $name: $revs"
(
# The following code was adapted from nix-prefetch-git
cd "$out/git/db/$name"
export GIT_DIR=.
# Remove all remote branches
git branch -r | while read branch; do
git branch -rD "$branch" >&2
done
# Remove all tags
git tag | while read tag; do
git tag -d "$tag" >&2
done
# Remove all local branches
branchrefs=()
eval "$(git for-each-ref --shell --format='branchrefs+=(%(refname))' refs/heads/)"
for branchref in "${branchrefs[@]}"; do
git update-ref -d "$branchref" >&2
done
# Create ad-hoc branches for the revs we need
echo "$revs" | while read -d " " rev; do
echo "Creating git branch b_$rev $rev"
git branch b_$rev $rev
done
# Remove files that have timestamps or otherwise have non-deterministic
# properties.
rm -rf logs/ hooks/ index FETCH_HEAD ORIG_HEAD refs/remotes/origin/HEAD config
# Do a full repack. Must run single-threaded, or else we lose determinism.
git config pack.threads 1
git repack -A -d -f
rm -f config
# Garbage collect unreferenced objects.
git gc --prune=all
)
done)
# Remove unneeded outputs
[[ ! -d $out/registry/src ]] || rm -rf $out/registry/src
[[ ! -d $out/git/checkouts ]] || rm -rf $out/git/checkouts
# XXX: provide some debugging output to see find out why we are seeing
# sporadic hash mismatches
find $out ! -type f
find $out -type f -exec sha256sum {} +
}

View file

@ -1,19 +1,30 @@
{ stdenv, cacert, git, rust, rustRegistry }:
{ stdenv, cacert, git, rust, cargoVendor }:
{ name ? "cargo-deps", src, srcs, sourceRoot, sha256, cargoUpdateHook ? "" }:
stdenv.mkDerivation {
name = "${name}-fetch";
buildInputs = [ rust.cargo rust.rustc git ];
inherit src srcs sourceRoot rustRegistry cargoUpdateHook;
name = "${name}-vendor";
buildInputs = [ cacert cargoVendor git rust.cargo ];
inherit src srcs sourceRoot;
phases = "unpackPhase installPhase";
installPhase = ''
source ${./fetch-cargo-deps}
if [[ ! -f Cargo.lock ]]; then
echo
echo "ERROR: The Cargo.lock file doesn't exist"
echo
echo "Cargo.lock is needed to make sure that cargoSha256 doesn't change"
echo "when the registry is updated."
echo
exit 1
fi
export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
export CARGO_HOME=$(mktemp -d cargo-home.XXX)
fetchCargoDeps . "$out"
cargo vendor
cp -ar vendor $out
'';
outputHashAlgo = "sha256";

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

View file

@ -3,17 +3,17 @@
with rustPlatform;
buildRustPackage rec {
version = "0.3.4";
version = "2017-06-23";
name = "loc-${version}";
src = fetchFromGitHub {
owner = "cgag";
repo = "loc";
rev = "9f3590f6299a1be3560f00de7f4f8bef61a02642";
sha256 = "0dga8prwnnmsa616jh64wzic957ff0491xghm0bjlns35ajc8lif";
rev = "bbea575f56879ef614d57a42a6b79fd45b9a8b38";
sha256 = "0agyhi55rh248fmlsip4fi1iw4xv3433q7bcb2lpjfnjpzxxlvfn";
};
depsSha256 = "1xcfhbnz208dk7xb748v8kv28zbhyr7wqg9gsgbiw3lnvc2a3nn6";
cargoSha256 = "0f3i8av9g19r2nhr9m8ca8s23kq294c5kqyvx155l6p76r7a9kvb";
meta = {
homepage = http://github.com/cgag/loc;

View file

@ -13,7 +13,7 @@ buildRustPackage rec {
sha256 = "1wxglc4n1dar5qphhj5pab7ps34cjr7jy611fwn72lz0f6c7jp3z";
};
depsSha256 = "0gkg3bxx7nxsvff33n7pif731djfvlzk0msia27h0wq0mazq7kw3";
cargoSha256 = "1pi8fh6vz6m5hr38wm0v0hxp1yxm1ma8yzish3b78zkv8f90kmv0";
meta = {
description = "Generate changelogs from local git metadata";

View file

@ -1,4 +1,4 @@
{ stdenv, fetchFromGitHub, rustPlatform, openssl, cmake, perl, pkgconfig, zlib }:
{ stdenv, fetchFromGitHub, fetchpatch, rustPlatform, openssl, cmake, perl, pkgconfig, zlib }:
with rustPlatform;
@ -13,14 +13,24 @@ buildRustPackage rec {
sha256 = "07mgq5h6r1gf3jflbv2khcz32bdazw7z1s8xcsafdarnm13ps014";
};
depsSha256 = "1xypk9ck7znca0nqm61m5ngpz6q7c0wydlpwxq4mnkd1np27xn53";
cargoSha256 = "06w864f73kijq24xzljfaf47d97aqyg4md3crzbq8hns157m3sv2";
cargoDepsHook = ''
(
cd ${name}-src
# see https://github.com/git-series/git-series/pull/56
patch -p1 < ${fetchpatch {
url = "https://github.com/Mic92/git-series/commit/3aa30a47d74ebf90b444dccdf8c153f07f119483.patch";
sha256 = "06v8br9skvy75kcw2zgbswxyk82sqzc8smkbqpzmivxlc2i9rnh0";
}}
)
'';
nativeBuildInputs = [ cmake pkgconfig perl ];
buildInputs = [ openssl zlib ];
postBuild = ''
mkdir -p "$out/man/man1"
cp "$src/git-series.1" "$out/man/man1"
install -D "$src/git-series.1" "$out/man/man1/git-series.1"
'';
meta = with stdenv.lib; {

View file

@ -11,7 +11,7 @@ rustPlatform.buildRustPackage rec {
sha256 = "1bzs3mr6f9bna39b9ddwwq0raas07nbn106mnq3widxg59i0gxhd";
};
depsSha256 = "1cz93mrpxmyrza0ipdyg2a6mynl66plpsb446wxnmmy7y7zd6xbf";
cargoSha256 = "0y0rkxhkv31v5sa0425dwskd80i6srwbqhqkrw1g1kbmbs9y0vxz";
installPhase = ''
mkdir -p $out/bin
@ -19,6 +19,7 @@ rustPlatform.buildRustPackage rec {
'';
meta = with stdenv.lib; {
broken = true;
description = "Count code, quickly";
homepage = https://github.com/Aaronepower/tokei;
license = licenses.mit;

View file

@ -13,7 +13,7 @@ buildRustPackage rec {
sha256 = "066f6sdy0vrp113wlg18q9p0clyrg9iqbj17ly0yn8dxr5iar002";
};
depsSha256 = "138h0q2a2gghfjpwfi11zw4rkipvmglb7srqz56ibbw2xliid2wl";
cargoSha256 = "0c4awm1d87b396d3g3mp1md5p92i5a64a9jdawpr8mwjd0bly05m";
buildInputs = [ llvmPackages.clang-unwrapped v8 ];

View file

@ -24,7 +24,7 @@ rustPlatform.buildRustPackage rec {
wrapProgram $out/bin/bindgen --set LIBCLANG_PATH "${llvmPackages.clang-unwrapped}/lib"
'';
depsSha256 = "06b5zyw9p7h73h30c1nlnwjb0zmkfx52wqsl9b14y9hx51g9bw0r";
cargoSha256 = "128skg31lc9v8i7ghfb3wyiazivqfvzhi1mvmjcl0gkx1hi5006v";
doCheck = false; # A test fails because it can't find standard headers in NixOS

View file

@ -11,7 +11,7 @@ rustPlatform.buildRustPackage rec {
sha256 = "06k50f2vj2w08afh3nrlhs0amcvw2i45bhfwr70sgs395xicjswp";
};
depsSha256 = "1gywnjbjl9jalbq6wkfmbczav4qbhgw2h8lyxkyppnhw9y4j0nc1";
cargoSha256 = "1w5imxyqlyv24dvzncq6dy01zn2x8p1aciyvzh8ac1x1wdjcacjc";
buildInputs = [ makeWrapper ];

View file

@ -14,7 +14,7 @@ buildRustPackage rec {
doCheck = false;
depsSha256 = "0db18m0vxzvg821gb5g8njhlnxw7im81m089i4982n8hmnhm1497";
cargoSha256 = "1h7hm7vkk1grah6pn5ydfi5pzc2kd48lh2kxim5jlvrxhd2dingg";
buildInputs = [ makeWrapper ];

View file

@ -13,9 +13,10 @@ buildRustPackage rec {
sha256 = "07vh4g120sx569wkzclq91blkkd7q7z582pl8vz0li1l9ij8md01";
};
depsSha256 = "1ckrf77s1glrqi0gvrv9wqmip4i97dk0arn0iz87jg4q2wfss85k";
cargoSha256 = "14kd25mw6m20blqcr221cclcqxw0j229zxq8hsaay6q7jgv0c7a0";
meta = with stdenv.lib; {
broken = true;
description = "Rust IDEs. parse-analysis";
homepage = https://github.com/RustDT/Rainicorn;
license = with licenses; [ mit asl20 ];

View file

@ -11,7 +11,7 @@ rustPlatform.buildRustPackage rec {
sha256 = "12l3ff0s0pzhcf5jbs8wqawjk4jghhhz8j6dq1n5201yvny12jlr";
};
depsSha256 = "1nnb2lpzjf6hv1a7cw3cbkc22fb54rsp6h87wzmqi4hsy1csff7a";
cargoSha256 = "0gppki9mgx99xipapg36ydwk1bplygnz6sbyzbg46vhn10iggfwm";
meta = with stdenv.lib; {
description = "A tool for formatting Rust code according to style guidelines";

View file

@ -6,7 +6,7 @@ rustPlatform.buildRustPackage rec {
name = "rustup-${version}";
version = "1.3.0";
depsSha256 = "078hssgffgpakv735p1xg60kic151r2dvpdr9sipb63lwqr4dxfb";
cargoSha256 = "1yd7k0jpx78p5bp6iyzgbyj7pjz8vyjg9g7fmf1bl60jsbdpgv3g";
src = fetchFromGitHub {
owner = "rust-lang-nursery";

View file

@ -14,7 +14,7 @@ rustPlatform.buildRustPackage rec {
buildInputs = [ perl zlib openssl ]
++ stdenv.lib.optional stdenv.isDarwin curl;
depsSha256 = "1lg1jh6f9w28i94vaj62r859g6raalxmxabvw7av6sqr0hr56p05";
cargoSha256 = "0c3324b7z77kiwc6whbppfmrli254fr1nyd0vpsxvpc0av3279jg";
meta = with stdenv.lib; {
description = "Twitter command-line interface written in rust";

View file

@ -13,7 +13,7 @@ buildRustPackage rec {
sha256 = "0c2haw9qiwysyp1xj6qla8d6zpsdlygagzh86sk04c2b4ssyaca3";
};
depsSha256 = "0w2jgbrcx57js8ihzs5acp6b1niw1c7khdxrv14y3z9mmm9j55hs";
cargoSha256 = "0ydi44710as0bb442zryzx30nk4mscdw3gsahwprnsvvaril33rn";
meta = with stdenv.lib; {
description = "Modern system shell with simple (and powerful) syntax";

View file

@ -14,7 +14,7 @@ buildRustPackage rec {
sha256 = "0j27qdgyxybaixggh7k57mpm6rifimn4z2vydk463msc8b3kgywj";
};
depsSha256 = "1n57i9wkak76ram748mwq0dn32d041ajd31laqc13c76pp29agrp";
cargoSha256 = "1fcl2nnplcic729cmvall2k7wf3jdm7dspvlbxji99bn813ackig";
buildInputs = [ openssl zeromq czmq zlib ];

View file

@ -14,7 +14,7 @@ buildRustPackage rec {
sha256 = "0c7ar3pc7n59lzfy74lwz51p09s2bglc870rfr4c0vmc91jl0pj2";
};
depsSha256 = "0wzr8hk63gh3nm8f7dbzwj8pgc3cm8p8mr2q7bbgvri1a5i83sfb";
cargoSha256 = "0q3mrcvl1yyrx4a88kanjlfcx6slf7r79i0dh4w81sj6gp07sssm";
buildInputs = [ openssl zeromq czmq zlib ];

View file

@ -14,7 +14,7 @@ buildRustPackage rec {
sha256 = "16a5fkpyqkf8w20k3ircc1d0qmif7nygkzxj6mzk9609dlb0dmxq";
};
depsSha256 = "0nax7h7f5qgalgxsfidrxrv1ybl5xvrpc1k7xc1kmaf955gqmc46";
cargoSha256 = "0qwbgwxrjc0dvjbpqa59jixy5nq7lng2c1z91rw48qc91v7fa664";
buildInputs = [ openssl zeromq czmq zlib ];

View file

@ -12,7 +12,7 @@ buildRustPackage rec {
sha256 = "0qy1g4crhfgs2f5cmrsjv6qscg3r66gb8n6sxhimm9ksivhjyyjp";
};
depsSha256 = "04jlz7nzsmg86i73w75i8rmlbk635xrg8m1dfac8h17dwb29yj6a";
cargoSha256 = "0dmn9bccicxhqcj9zrsxxp0vb5ma12a1hs9brpc22n4g1qy4yzcn";
buildInputs = [ lzo zlib ];

View file

@ -6,7 +6,7 @@ buildRustPackage rec {
name = "exa-${version}";
version = "0.8.0";
depsSha256 = "0yz41prkjs5rmvdhr9k58a52l7hvwy5mfg8rcpsq4ybgf601lja2";
cargoSha256 = "08zzn3a32xfjkmpawcjppn1mr26ws3iv40cckiz8ldz4qc8y9gdh";
src = fetchFromGitHub {
owner = "ogham";

View file

@ -11,7 +11,7 @@ rustPlatform.buildRustPackage rec {
sha256 = "1aw4pgsmvzzqlvbxzv5jnw42nf316qfhvr50b58iqi2dxy8z8cmv";
};
depsSha256 = "17fjlmdwp8582dvv68b5h3zzvmd71yd9sw9xalyrrww46h7fd84g";
cargoSha256 = "1v9wg4dq4c7i85bkdhd79bj8gx7200z6np05wsyj2ycbv97p095j";
meta = {
description = "A simple, fast and user-friendly alternative to find";

View file

@ -13,7 +13,7 @@ buildRustPackage rec {
sha256 = "1fcrbjwnhcz71i70ppy0rcgk5crwwmbkm9nrk1kapvks33pv0az7";
};
depsSha256 = "05mj84a5k65ai492grwg03c3wq6ardhs114bv951fgysc9rs07p5";
cargoSha256 = "0kqkzjd90v19qvl3iv1vv2fi8h0z75b0yn0z5jq8w4m94fvh0p95";
# some tests require a tty, this variable turns them off for Travis CI,
# which we can also make use of

View file

@ -15,7 +15,7 @@ buildRustPackage rec {
buildInputs = [ zlib openssl ];
depsSha256 = "1v7ir56j6biximnnhyvadd98azcj3i5hc8aky0am2nf0swq0jimq";
cargoSha256 = "1m4yb7472g1n900dh3xqvdcywk3v01slj3bkk7bk7a9p5x1kyjfn";
meta = with stdenv.lib; {
description = "A utility for managing cargo dependencies from the command line";
@ -23,5 +23,6 @@ buildRustPackage rec {
license = with licenses; [ mit ];
maintainers = with maintainers; [ jb55 ];
platforms = platforms.all;
broken = true;
};
}

View file

@ -12,7 +12,7 @@ buildRustPackage rec {
rev = "v${version}";
sha256 = "1lmg65yqkwf2a5qxm3dmv8158kqhnriir062vlgar5wimf409rm5";
};
depsSha256 = "0v145fi9bfiwvsdy7hz9lw4m2f2j8sxvixfzmjwfnq4klm51c8yl";
cargoSha256 = "0cxdrzjmqq3ywdh0f5mzkcf50hbbgd3bak4398v2ls5gy5s9fcz2";
nativeBuildInputs = [ pkgconfig ];
buildInputs = [ openssl curl];

View file

@ -13,7 +13,7 @@ buildRustPackage rec {
sha256 = "1cnvwxbznmsn1gand8hhy5zadax5p67lvm46fkj1a1s89f158w3a";
};
depsSha256 = "1kx9xazhj93xa3cnys39wwr84qqjqrlsbbi5ih71vxppskdpvd6m";
cargoSha256 = "00y2vdnrg02clqin9pg57s9micrp66f6y49wq89cmykrfg3r8cwf";
preFixup = ''
mkdir -p "$out/man/man1"

View file

@ -11,9 +11,10 @@ rustPlatform.buildRustPackage rec {
sha256 = "1zbd1gx0ik2r7bavcid776j37g6rzd3f6cs94kq1qar4gyf1gqjm";
};
depsSha256 = "1gwfkh3ck8n3zcy43ch2mnc28a6y10p3srhnx9dh8gwnwbpb733c";
cargoSha256 = "074mfyanwdykg6wci2ia63wcnnyik741g8n624pac215sg4i95h7";
meta = {
broken = true;
description = "A command line program that lets you compute statistics from values from a file or standard input";
longDescription = ''
Staccato (`st` for short) is a command line program that lets you

View file

@ -13,7 +13,7 @@ buildRustPackage rec {
sha256 = "0z1z3b6nzaid510jaikkawvpmv4kjphzz84p0hppq6vcp5jy00s2";
};
depsSha256 = "13hy835871zxdnakwsr4bjm4krahlz4aqk5lh0rw78avfla89q9q";
cargoSha256 = "0pdzh2xr40dgwravh3i58g602bpszj6c8inggzgmq2kfk8ck6rgj";
meta = with stdenv.lib; {
description = "A fast CSV toolkit written in Rust";

View file

@ -14,7 +14,7 @@ buildRustPackage rec {
sha256 = "0k5vkn112bjwh4wnxryzqz79dlja64k7s105mf3yaik136hqnmqv";
};
depsSha256 = "1vxvkh1v9x6j4ggbh6sysi5i3089hrs0mjbp910a1jljiav7l8nj";
cargoSha256 = "03bqhgz8c4ipdkd3g448bcrr6d188h87vskcfcc3mqlcxg77b8q5";
nativeBuildInputs = [ pkgconfig ];

View file

@ -130,7 +130,6 @@ mapAliases (rec {
robomongo = robo3t; #added 2017-09-28
rssglx = rss-glx; #added 2015-03-25
rubygems = throw "deprecated 2016-03-02: rubygems is now bundled with ruby";
rustUnstable = rustNightly; # added 2016-11-29
rxvt_unicode_with-plugins = rxvt_unicode-with-plugins; # added 2015-04-02
samsungUnifiedLinuxDriver = samsung-unified-linux-driver; # added 2016-01-25
saneBackends = sane-backends; # added 2016-01-02

View file

@ -6179,8 +6179,6 @@ with pkgs;
rust = callPackage ../development/compilers/rust { };
inherit (rust) cargo rustc;
rustRegistry = callPackage ./rust-packages.nix { };
rustPlatform = recurseIntoAttrs (makeRustPlatform rust);
makeRustPlatform = rust: lib.fix (self:

View file

@ -1,46 +0,0 @@
# This file defines the source of Rust / cargo's crates registry
#
# buildRustPackage will automatically download dependencies from the registry
# version that we define here. If you're having problems downloading / finding
# a Rust library, try updating this to a newer commit.
{ stdenv, fetchFromGitHub, git }:
stdenv.mkDerivation {
name = "rustRegistry-2017-10-08";
src = fetchFromGitHub {
owner = "rust-lang";
repo = "crates.io-index";
rev = "78ab44cf22c2ce5d40e562ffc7df7ab10ac12b86";
sha256 = "0fa3l3px6b89ap63h40bhn2x50zf5j65jrgbb7j103j0cdayk2l0";
};
phases = [ "unpackPhase" "installPhase" ];
installPhase = ''
# For some reason, cargo doesn't like fetchgit's git repositories, not even
# if we set leaveDotGit to true, set the fetchgit branch to 'master' and clone
# the repository (tested with registry rev
# 965b634156cc5c6f10c7a458392bfd6f27436e7e), failing with the message:
#
# "Target OID for the reference doesn't exist on the repository"
#
# So we'll just have to create a new git repository from scratch with the
# contents downloaded with fetchgit...
mkdir -p $out
cp -r ./* $out/
cd $out
git="${git}/bin/git"
$git init
$git config --local user.email "example@example.com"
$git config --local user.name "example"
$git add .
$git commit --quiet -m 'Rust registry commit'
touch $out/touch . "$out/.cargo-index-lock"
'';
}