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,4 +1,4 @@
{ stdenv, cacert, git, cargo, rustRegistry }:
{ stdenv, cacert, git, rust, rustRegistry }:
{ name, depsSha256
, src ? null
, srcs ? null
@ -10,7 +10,7 @@
let
fetchDeps = import ./fetchcargo.nix {
inherit stdenv cacert git cargo rustRegistry;
inherit stdenv cacert git rust rustRegistry;
};
cargoDeps = fetchDeps {
@ -23,7 +23,7 @@ in stdenv.mkDerivation (args // {
patchRegistryDeps = ./patch-registry-deps;
buildInputs = [ git cargo cargo.rustc ] ++ buildInputs;
buildInputs = [ git rust.cargo rust.rustc ] ++ buildInputs;
configurePhase = args.configurePhase or "true";

View File

@ -1,9 +1,9 @@
{ stdenv, cacert, git, cargo, rustRegistry }:
{ stdenv, cacert, git, rust, rustRegistry }:
{ name ? "cargo-deps", src, srcs, sourceRoot, sha256, cargoUpdateHook ? "" }:
stdenv.mkDerivation {
name = "${name}-fetch";
buildInputs = [ cargo git ];
buildInputs = [ rust.cargo rust.rustc git ];
inherit src srcs sourceRoot rustRegistry cargoUpdateHook;
phases = "unpackPhase installPhase";

View File

@ -0,0 +1,27 @@
{ stdenv, callPackage, rustPlatform,
targets ? [], targetToolchains ? [], targetPatches ? [] }:
rec {
rustc = callPackage ./rustc.nix {
shortVersion = "beta-1.10.0";
forceBundledLLVM = false;
configureFlags = [ "--release-channel=beta" ];
srcRev = "d18e321abeecc69e4d1bf9cafba4fba53ddf267d";
srcSha = "1ck8mbjrq0bzq5xzwgaqdilakwm2ab0xpzqibjycds62ad4yw774";
patches = [ ./patches/disable-lockfile-check.patch ]
++ stdenv.lib.optional stdenv.needsPax ./patches/grsec.patch;
inherit targets;
inherit targetPatches;
inherit targetToolchains;
inherit rustPlatform;
};
cargo = callPackage ./cargo.nix rec {
version = "0.10.0";
srcRev = "refs/tags/${version}";
srcSha = "06scvx5qh60mgvlpvri9ig4np2fsnicsfd452fi9w983dkxnz4l2";
depsSha256 = "0js4697n7v93wnqnpvamhp446w58llj66za5hkd6wannmc0gsy3b";
inherit rustc; # the rustc that will be wrapped by cargo
inherit rustPlatform; # used to build cargo
};
}

View File

@ -1,4 +1,4 @@
{ stdenv, fetchurl, makeWrapper, cacert, zlib, rustc }:
{ stdenv, fetchurl, makeWrapper, cacert, zlib }:
let
platform =
@ -23,28 +23,56 @@ let
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"];
version = "1.9.0";
in
installPhase = ''
cp -r cargo "$out"
rec {
rustc = stdenv.mkDerivation rec {
name = "rustc-bootstrap-${version}";
patchelf \
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
"$out/bin/cargo"
inherit version;
inherit src;
wrapProgram "$out/bin/cargo" \
--suffix PATH : "${rustc}/bin"
'';
buildInputs = [ makeWrapper ];
phases = ["unpackPhase" "installPhase"];
installPhase = ''
./install.sh --prefix=$out \
--components=rustc,rust-std-${platform},rust-docs
patchelf \
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
"$out/bin/rustc"
wrapProgram "$out/bin/rustc"
'';
};
cargo = stdenv.mkDerivation rec {
name = "cargo-bootstrap-${version}";
inherit version;
inherit src;
buildInputs = [ makeWrapper zlib rustc ];
phases = ["unpackPhase" "installPhase"];
installPhase = ''
./install.sh --prefix=$out \
--components=cargo
patchelf \
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
"$out/bin/cargo"
wrapProgram "$out/bin/cargo" \
--suffix PATH : "${rustc}/bin"
'';
};
}

View File

@ -20,7 +20,7 @@ rustPlatform.buildRustPackage rec {
++ stdenv.lib.optional stdenv.isDarwin libiconv;
configurePhase = ''
./configure --enable-optimize --prefix=$out --local-cargo=${rustPlatform.cargo}/bin/cargo
./configure --enable-optimize --prefix=$out --local-cargo=${rustPlatform.rust.cargo}/bin/cargo
'';
buildPhase = "make";

View File

@ -0,0 +1,33 @@
{ stdenv, callPackage, recurseIntoAttrs, makeRustPlatform,
targets ? [], targetToolchains ? [], targetPatches ? [] }:
let
rustPlatform = recurseIntoAttrs (makeRustPlatform (callPackage ./bootstrap.nix {}) rustPlatform);
rustSnapshotPlatform = recurseIntoAttrs (makeRustPlatform (callPackage ./snapshot.nix {}) rustPlatform);
in
rec {
rustc = callPackage ./rustc.nix {
shortVersion = "1.9.0";
isRelease = true;
forceBundledLLVM = false;
configureFlags = [ "--release-channel=stable" ];
srcRev = "e4e8b666850a763fdf1c3c2c142856ab51e32779";
srcSha = "1pz4qx70mqv78fxm4w1mq7csk5pssq4qmr2vwwb5v8hyx03caff8";
patches = [ ./patches/remove-uneeded-git.patch ]
++ stdenv.lib.optional stdenv.needsPax ./patches/grsec.patch;
inherit targets;
inherit targetPatches;
inherit targetToolchains;
rustPlatform = rustSnapshotPlatform;
};
cargo = callPackage ./cargo.nix rec {
version = "0.10.0";
srcRev = "refs/tags/${version}";
srcSha = "06scvx5qh60mgvlpvri9ig4np2fsnicsfd452fi9w983dkxnz4l2";
depsSha256 = "0js4697n7v93wnqnpvamhp446w58llj66za5hkd6wannmc0gsy3b";
inherit rustc; # the rustc that will be wrapped by cargo
inherit rustPlatform; # used to build cargo
};
}

View File

@ -0,0 +1,27 @@
{ stdenv, callPackage, rustPlatform,
targets ? [], targetToolchains ? [], targetPatches ? [] }:
rec {
rustc = callPackage ./rustc.nix {
shortVersion = "master-1.11.0";
forceBundledLLVM = false;
srcRev = "298730e7032cd55809423773da397cd5c7d827d4";
srcSha = "0hyz5j1z75sjkgsifzgxviv3b1lhgaz8wqwvmq80xx5vd78yd0c1";
patches = [ ./patches/disable-lockfile-check.patch
./patches/use-rustc-1.9.0.patch ]
++ stdenv.lib.optional stdenv.needsPax ./patches/grsec.patch;
inherit targets;
inherit targetPatches;
inherit targetToolchains;
inherit rustPlatform;
};
cargo = callPackage ./cargo.nix rec {
version = "2016.06.07";
srcRev = "3e70312a2a4ebedace131fc63bb8f27463c5db28";
srcSha = "0nibzyfjkiqfnq0c00hhqvs856l5qls8wds252p97q5q92yvp40f";
depsSha256 = "1xbb33aqnf5yyws6gjys9w8kznbh9rh6hw8mpg1hhq1ahipc2j1f";
inherit rustc; # the rustc that will be wrapped by cargo
inherit rustPlatform; # used to build cargo
};
}

View File

@ -1,5 +1,5 @@
{ stdenv, fetchurl, fetchgit, fetchzip, file, python2, tzdata, procps
, llvm, jemalloc, ncurses, darwin, binutils, rustc, git
, llvm, jemalloc, ncurses, darwin, binutils, rustPlatform, git
, isRelease ? false
, shortVersion
@ -8,6 +8,7 @@
, configureFlags ? []
, patches
, targets
, targetPatches
, targetToolchains
} @ args:
@ -51,14 +52,14 @@ stdenv.mkDerivation {
# We need rust to build rust. If we don't provide it, configure will try to download it.
configureFlags = configureFlags
++ [ "--enable-local-rust" "--local-rust-root=${rustc}" "--enable-rpath" ]
++ [ "--enable-local-rust" "--local-rust-root=${rustPlatform.rust.rustc}" "--enable-rpath" ]
# ++ [ "--jemalloc-root=${jemalloc}/lib"
++ [ "--default-linker=${stdenv.cc}/bin/cc" "--default-ar=${binutils.out}/bin/ar" ]
++ stdenv.lib.optional (stdenv.cc.cc ? isClang) "--enable-clang"
++ stdenv.lib.optional (targets != []) "--target=${target}"
++ stdenv.lib.optional (!forceBundledLLVM) "--llvm-root=${llvmShared}";
inherit patches;
patches = patches ++ targetPatches;
passthru.target = target;
postPatch = ''
@ -94,7 +95,7 @@ stdenv.mkDerivation {
'';
# ps is needed for one of the test cases
nativeBuildInputs = [ file python2 procps rustc git ];
nativeBuildInputs = [ file python2 procps rustPlatform.rust.rustc git ];
buildInputs = [ ncurses ] ++ targetToolchains
++ stdenv.lib.optional (!forceBundledLLVM) llvmShared;

View File

@ -2,7 +2,7 @@
This file can be deleted after the 1.10.0 release and bootstrap.nix
can be used instead
*/
{ stdenv, fetchurl }:
{ stdenv, fetchurl, callPackage }:
let
platform = if stdenv.system == "i686-linux"
@ -43,19 +43,23 @@ let
snapshotName = "rust-stage0-${snapshotDate}-${snapshotRev}-${platform}-${snapshotHash}.tar.bz2";
in
stdenv.mkDerivation {
name = "rust-bootstrap";
src = fetchurl {
url = "http://static.rust-lang.org/stage0-snapshots/${snapshotName}";
sha1 = snapshotHash;
rec {
rustc = stdenv.mkDerivation {
name = "rustc-snapshot";
src = fetchurl {
url = "http://static.rust-lang.org/stage0-snapshots/${snapshotName}";
sha1 = snapshotHash;
};
dontStrip = true;
installPhase = ''
mkdir -p "$out"
cp -r bin "$out/bin"
'' + stdenv.lib.optionalString stdenv.isLinux ''
patchelf --interpreter "${stdenv.glibc.out}/lib/${stdenv.cc.dynamicLinker}" \
--set-rpath "${stdenv.cc.cc.lib}/lib/:${stdenv.cc.cc.lib}/lib64/" \
"$out/bin/rustc"
'';
};
dontStrip = true;
installPhase = ''
mkdir -p "$out"
cp -r bin "$out/bin"
'' + stdenv.lib.optionalString stdenv.isLinux ''
patchelf --interpreter "${stdenv.glibc.out}/lib/${stdenv.cc.dynamicLinker}" \
--set-rpath "${stdenv.cc.cc.lib}/lib/:${stdenv.cc.cc.lib}/lib64/" \
"$out/bin/rustc"
'';
cargo = null;
}

View File

@ -1,14 +0,0 @@
{ stdenv, callPackage, rustcStable, targets ? [], targetToolchains ? [] }:
callPackage ./generic.nix {
shortVersion = "beta-1.10.0";
forceBundledLLVM = false;
configureFlags = [ "--release-channel=beta" ];
srcRev = "39f3c16cca889ef3f1719d9177e3315258222a65";
srcSha = "01bx6616lslp2mbj4h8bb6m042fs0y1z8g0jgpxvbk3fbhzwafrx";
patches = [ ./patches/disable-lockfile-check.patch ] ++
stdenv.lib.optional stdenv.needsPax ./patches/grsec.patch;
rustc = rustcStable;
inherit targets;
inherit targetToolchains;
}

View File

@ -1,47 +0,0 @@
{ stdenv, fetchurl, makeWrapper }:
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 "2951dec835827974d03c7aafbf2c969f39bb530e1c200fd46f90bc01772fae39"
else if stdenv.system == "x86_64-linux"
then "d0704d10237c66c3efafa6f7e5570c59a1d3fe5c6d99487540f90ebb37cd84c4"
else if stdenv.system == "i686-darwin"
then "c7aa93e2475aa8e65259f606ca70e98da41cf5d2b20f91703b98f9572a84f7e6"
else if stdenv.system == "x86_64-darwin"
then "7204226b42e9c380d44e722efd4a886178a1867a064c90f12e0553a21a4184c6"
else throw "missing boostrap hash for platform ${stdenv.system}";
in
stdenv.mkDerivation rec {
name = "rustc-bootstrap-${version}";
version = "1.9.0";
src = fetchurl {
url = "https://static.rust-lang.org/dist/rustc-${version}-${platform}.tar.gz";
sha256 = bootstrapHash;
};
buildInputs = [makeWrapper];
phases = ["unpackPhase" "installPhase"];
installPhase = ''
mkdir -p "$out"
./install.sh "--prefix=$out"
patchelf \
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
"$out/bin/rustc"
wrapProgram "$out/bin/rustc"
'';
}

View File

@ -1,15 +0,0 @@
{ stdenv, callPackage, targets ? [], targetToolchains ? [] }:
callPackage ./generic.nix {
shortVersion = "1.9.0";
isRelease = true;
forceBundledLLVM = false;
configureFlags = [ "--release-channel=stable" ];
srcRev = "e4e8b666850a763fdf1c3c2c142856ab51e32779";
srcSha = "167rh7hs77grn895h54s7np7f0k7b6i8z4wdfinncg4chy08hxq1";
patches = [ ./patches/remove-uneeded-git.patch ]
++ stdenv.lib.optional stdenv.needsPax ./patches/grsec.patch;
rustc = callPackage ./snapshot.nix {};
inherit targets;
inherit targetToolchains;
}

View File

@ -1,15 +0,0 @@
# Please make sure to check if rustfmt still builds when updating nightly
{ stdenv, callPackage, rustcStable, targets ? [], targetToolchains ? [] }:
callPackage ./generic.nix {
shortVersion = "master-1.11.0";
forceBundledLLVM = false;
srcRev = "298730e7032cd55809423773da397cd5c7d827d4";
srcSha = "0hyz5j1z75sjkgsifzgxviv3b1lhgaz8wqwvmq80xx5vd78yd0c1";
patches = [ ./patches/disable-lockfile-check.patch
./patches/use-rustc-1.9.0.patch ] ++
stdenv.lib.optional stdenv.needsPax ./patches/grsec.patch;
rustc = rustcStable;
inherit targets;
inherit targetToolchains;
}

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/rustc-$VERSION-$PLATFORM.tar.gz.sha256"
curl $URL
done

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,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

@ -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

View File

@ -1,7 +1,7 @@
# TODO check that no license information gets lost
{ fetchurl, bash, stdenv, python, go, cmake, vim, vimUtils, perl, ruby, unzip
, which, fetchgit, fetchFromGitHub, fetchhg, fetchzip, llvmPackages, zip
, vim_configurable, vimPlugins, xkb_switch, git, racerdRust, fzf
, vim_configurable, vimPlugins, xkb_switch, git, rustracerd, fzf
, Cocoa ? null
}:
@ -1116,7 +1116,7 @@ rec {
] ++ stdenv.lib.optional stdenv.isDarwin Cocoa;
propogatedBuildInputs = [
racerdRust
rustracerd
];
buildPhase = ''

View File

@ -5,7 +5,7 @@
] ++ stdenv.lib.optional stdenv.isDarwin Cocoa;
propogatedBuildInputs = [
racerdRust
rustracerd
];
buildPhase = ''

View File

@ -6,7 +6,7 @@ buildRustPackage rec {
name = "exa-${version}";
version = "2016-04-20";
depsSha256 = "1rpynsni2r3gim10xc1qkj51wpbzafwsr99y61zh41v4vh047g1k";
depsSha256 = "0dm8zaxy29pfbq68ysssab9i06sj4azgi3vib9617rklg7w3hdmk";
src = fetchFromGitHub {
owner = "ogham";

View File

@ -5261,32 +5261,31 @@ in
rtags = callPackage ../development/tools/rtags/default.nix {};
rustc = rustcStable;
rustcStable = callPackage ../development/compilers/rustc {};
rustcBeta = lowPrio (callPackage ../development/compilers/rustc/beta.nix {});
rustcUnstable = lowPrio (callPackage ../development/compilers/rustc/head.nix {});
rust = rustStable;
rustStable = callPackage ../development/compilers/rust {};
rustBeta = lowPrio (callPackage ../development/compilers/rust/beta.nix {});
rustUnstable = lowPrio (callPackage ../development/compilers/rust/head.nix {});
cargo = callPackage ../development/tools/build-managers/cargo {};
cargoUnstable = lowPrio (callPackage ../development/tools/build-managers/cargo/head.nix {});
cargo = rust.cargo;
rustc = rust.rustc;
rustPlatform = recurseIntoAttrs (makeRustPlatform rust rustPlatform);
rustPlatform = recurseIntoAttrs (makeRustPlatform cargo rustPlatform);
makeRustPlatform = cargo: self:
makeRustPlatform = rust: self:
let
callPackage = newScope self;
in {
inherit cargo;
rustc = cargo.rustc;
inherit rust;
rustRegistry = callPackage ./rust-packages.nix { };
buildRustPackage = callPackage ../build-support/rust {
inherit cargo;
inherit rust;
};
};
rustfmt = callPackage ../development/tools/rust/rustfmt { };
rustracer = callPackage ../development/tools/rust/racer { };
rustracerd = callPackage ../development/tools/rust/racerd { };
sbclBootstrap = callPackage ../development/compilers/sbcl/bootstrap.nix {};
sbcl = callPackage ../development/compilers/sbcl {};
@ -6363,10 +6362,6 @@ in
withDocumentation = false; # 'true' is currently broken with qt>=5.5
};
racerRust = callPackage ../development/tools/rust/racer { };
racerdRust = callPackage ../development/tools/rust/racerd { };
radare = callPackage ../development/tools/analysis/radare {
inherit (gnome) vte;
lua = lua5;
@ -7494,7 +7489,7 @@ in
};
libkrb5 = self.krb5Full.override { type = "lib"; };
lasso = callPackage ../development/libraries/lasso { };
lasso = callPackage ../development/libraries/lasso { };
LASzip = callPackage ../development/libraries/LASzip { };