Skip to content

Commit

Permalink
Merge pull request #30088 from zimbatm/rust-1.20.0
Browse files Browse the repository at this point in the history
Rust 1.20.0
  • Loading branch information
zimbatm authored Oct 22, 2017
2 parents 97d02a7 + 6bbce42 commit 2d59a62
Show file tree
Hide file tree
Showing 55 changed files with 218 additions and 614 deletions.
21 changes: 10 additions & 11 deletions doc/languages-frameworks/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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";
Expand All @@ -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.
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/altcoins/ethabi.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ buildRustPackage rec {
sha256 = "1rg7ydvnhlg8w6blilm3cv6v4q51x1hgrbkln2ikhpdq0vakp5fd";
};

depsSha256 = "1n4rxipna307r4xppb2iaads7kpa3yjv99fimvpn8l0f999ir2rz";
cargoSha256 = "0i9617qwc6d4jvlbydwk03rcsnyvxzpbn2ms10ds4r6x7jy2a4sy";

cargoBuildFlags = ["--features cli"];

Expand Down
3 changes: 2 additions & 1 deletion pkgs/applications/altcoins/ethrun.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
}
2 changes: 1 addition & 1 deletion pkgs/applications/altcoins/zcash/librustzcash/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ rustPlatform.buildRustPackage rec {
sha256 = "02l1f46frpvw1r6k1wfh77mrsnmsdvifqx0vnscxz4xgb9ia9d1c";
};

depsSha256 = "02qx8zdhmj7rmhqqq5q9428x9mlrjxxcnn4yhnygz9gfgvada2hx";
cargoSha256 = "1b0kal53ggcr59hbrsdj8fifjycahrmzwq677n9h3fywv4r237m6";

installPhase = ''
mkdir -p $out/lib
Expand Down
3 changes: 2 additions & 1 deletion pkgs/applications/misc/alacritty/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ buildRustPackage rec {
sha256 = "0h37x12r33xwz9vf1n8y24c0ph5w17lhkpfi5q6lbpgidvbs6fyx";
};

depsSha256 = "05gkl2zg546i2pm0gx11s56f7dk72qpm39kml1d2myj81s0vyb5z";
cargoSha256 = "0w3j92kd27pny37pfvlv6qsnbb1lgphmfbhvvng0z96r2b1wjviz";

buildInputs = [
cmake
Expand Down Expand Up @@ -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 ];
Expand Down
3 changes: 2 additions & 1 deletion pkgs/applications/networking/cluster/habitat/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ buildRustPackage rec {
sha256 = "0pqrm85pd9hqn5fwqjbyyrrfh4k7q9mi9qy9hm8yigk5l8mw44y1";
};

depsSha256 = "1ahfm5agvabqqqgjsyjb95xxbc7mng1mdyclcakwp1m1qdkxx9py";
cargoSha256 = "1ahfm5agvabqqqgjsyjb95xxbc7mng1mdyclcakwp1m1qdkxx9p0";

buildInputs = [ libsodium libarchive openssl ];

Expand All @@ -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
};
}
2 changes: 1 addition & 1 deletion pkgs/applications/networking/dyndns/cfdyndns/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ buildRustPackage rec {
sha256 = "1mcdjykrgh0jq6k6y664lai8sbgzk6j7k0r944f43vg63d1jql5b";
};

depsSha256 = "0whs3fgmpb6g1mjajs3qs9g613x5dal4x6ghzzkpl73a9pgydkpn";
cargoSha256 = "0k9d6pxsb4gvkqs00g71c1nnz773iccg4vajgn33qdym6m6qsjwy";

buildInputs = [ makeWrapper openssl ];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ buildRustPackage rec {
sha256 = "1sx6sc2dj3l61gbiqz8vfyhw5w4xjdyfzn1ixz0y8ipm579yc7a2";
};

depsSha256 = "1z2n3z5wkh5z5vc976yscq77fgjszwzwlrp7g17hmsbhzx6x170h";
cargoSha256 = "08zbvjwjdpv2sbj6mh73py82inhs18jvmh8m9k4l94fcz6ykgqwr";

nativeBuildInputs = [
cmake
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/version-management/pijul/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ buildRustPackage rec {

doCheck = false;

depsSha256 = "1qzzpnkyw1bn5fnj06c80f7985v1q0rqcphrrrkpbi33lg5mzgbv";
cargoSha256 = "0r69vghjd6b30v0qjsipyv56n92iwvyxmllrnwjzjf5pzhhjl7sy";

meta = with stdenv.lib; {
description = "A distributed version control system";
Expand Down
3 changes: 2 additions & 1 deletion pkgs/applications/window-managers/way-cooler/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion pkgs/applications/window-managers/wtftw/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ rustPlatform.buildRustPackage rec {
sha256 = "1r74nhcwiy2rmifzjhdal3jcqz4jz48nfvhdyw4gasa6nxp3msdl";
};

depsSha256 = "0z7h8ybh2db3xl8qxbzby5lncdaijixzmbn1j8a45lbky1xiix71";
cargoSha256 = "0z92ml84b5652zgwzn08a8vvxksaa54jql66sfpdz1mvjwhgdmvn";

nativeBuildInputs = [ pkgconfig ];
buildInputs = [ libXinerama libX11 ];
Expand All @@ -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;
Expand Down
32 changes: 32 additions & 0 deletions pkgs/build-support/rust/cargo-vendor.nix
Original file line number Diff line number Diff line change
@@ -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
'';

This comment has been minimized.

Copy link
@dtzWill

dtzWill Oct 23, 2017

Member

meta description and license, please!

}
89 changes: 22 additions & 67 deletions pkgs/build-support/rust/default.nix
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;

Expand All @@ -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
'';

Expand All @@ -126,4 +79,6 @@ in stdenv.mkDerivation (args // {
find target/release -maxdepth 1 -executable -exec cp "{}" $out/bin \;
runHook postInstall
'';

passthru = { inherit cargoDeps; };
})
Loading

0 comments on commit 2d59a62

Please sign in to comment.