Add support for building cargo'ed Rust programs

This commit is contained in:
Georges Dubus
2014-10-10 16:59:37 +02:00
committed by Ricardo M. Correia
parent c55c7e1c1e
commit 7d67efa3f2
12 changed files with 310 additions and 18 deletions

View File

@@ -3,6 +3,16 @@
{
inherit version;
name = "cargo-${version}";
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"
'';
platform = if stdenv.system == "i686-linux"
then "i686-unknown-linux-gnu"
else if stdenv.system == "x86_64-linux"
@@ -20,5 +30,5 @@
platforms = platforms.linux;
};
name = "cargo-${version}";
setupHook = ./setup-hook.sh;
}

View File

@@ -0,0 +1,32 @@
{ stdenv, fetchgit, rustPlatform, file, curl, python, pkgconfig, openssl
, cmake, zlib }:
with ((import ./common.nix) { inherit stdenv; version = "2015-04-14"; });
with rustPlatform;
buildRustPackage rec {
inherit name version meta setupHook;
src = fetchgit {
url = "https://github.com/rust-lang/cargo.git";
rev = "d49b44358ed800351647571144257d35ac0886cf";
sha256 = "1kaims28237mvp1qpw2cfgb3684jr54ivkdag0lw8iv9xap4i35y";
leaveDotGit = true;
};
depsSha256 = "1yi39asmnrya8w83jrjxym658cf1a5ffp8ym8502rqqvx30y0yx4";
buildInputs = [ file curl pkgconfig python openssl cmake zlib ];
configurePhase = ''
./configure --prefix=$out --local-cargo=${cargo}/bin/cargo
'';
buildPhase = "make";
installPhase = ''
make install
${postInstall}
'';
}

View File

@@ -0,0 +1,6 @@
if [[ -n "$cargoDeps" ]]; then
echo "Using cargo deps from $cargoDeps"
cp -r $cargoDeps deps
chmod +w deps -R
export CARGO_HOME=$(realpath deps)
fi

View File

@@ -19,11 +19,8 @@ let snapshotHash = if stdenv.system == "i686-linux"
snapshotName = "cargo-nightly-${platform}.tar.gz";
in
stdenv.mkDerivation {
inherit name;
inherit version;
inherit meta;
inherit name version meta setupHook;
src = fetchurl {
url = "https://static-rust-lang-org.s3.amazonaws.com/cargo-dist/${snapshotDate}/${snapshotName}";
@@ -35,10 +32,8 @@ stdenv.mkDerivation {
installPhase = ''
mkdir -p "$out"
./install.sh "--prefix=$out"
rm "$out/lib/rustlib/components" \
"$out/lib/rustlib/install.log" \
"$out/lib/rustlib/rust-installer-version" \
"$out/lib/rustlib/uninstall.sh"
${postInstall}
'' + (if stdenv.isLinux then ''
patchelf --interpreter "${stdenv.glibc}/lib/${stdenv.cc.dynamicLinker}" \
--set-rpath "${stdenv.cc.cc}/lib/:${stdenv.cc.cc}/lib64/:${zlib}/lib" \

View File

@@ -1,6 +1,8 @@
{stdenv, fetchgit, rustc, cargo, makeWrapper }:
{stdenv, fetchgit, rustPlatform, makeWrapper }:
stdenv.mkDerivation rec {
with rustPlatform;
buildRustPackage rec {
#TODO add emacs support
name = "racer-git-2015-04-12";
src = fetchgit {
@@ -9,11 +11,9 @@ stdenv.mkDerivation rec {
sha256 = "0a768gvjry86l0xa5q0122iyq7zn2h9adfniglsgrbs4fan49xyn";
};
buildInputs = [ rustc cargo makeWrapper ];
depsSha256 = "0x1rq012k04ci18w5fll56jn011f1yyprs38pb3r223bag94ivsy";
buildPhase = ''
CARGO_HOME="$NIX_BUILD_TOP/.cargo" cargo build --release
'';
buildInputs = [ makeWrapper ];
installPhase = ''
mkdir -p $out/bin