diff options
author | Georges Dubus <georges.dubus@numergy.com> | 2014-10-10 16:59:37 +0200 |
---|---|---|
committer | Ricardo M. Correia <rcorreia@wizy.org> | 2015-04-21 19:46:29 +0200 |
commit | 7d67efa3f23f7d5c494c90b79a63756a3917be6e (patch) | |
tree | fc8e6121cc18c9d26bba5107a903a8a499501e2a /pkgs/development/tools | |
parent | c55c7e1c1e09dfa57e1a44d08c777f995493d2c9 (diff) | |
download | nixlib-7d67efa3f23f7d5c494c90b79a63756a3917be6e.tar nixlib-7d67efa3f23f7d5c494c90b79a63756a3917be6e.tar.gz nixlib-7d67efa3f23f7d5c494c90b79a63756a3917be6e.tar.bz2 nixlib-7d67efa3f23f7d5c494c90b79a63756a3917be6e.tar.lz nixlib-7d67efa3f23f7d5c494c90b79a63756a3917be6e.tar.xz nixlib-7d67efa3f23f7d5c494c90b79a63756a3917be6e.tar.zst nixlib-7d67efa3f23f7d5c494c90b79a63756a3917be6e.zip |
Add support for building cargo'ed Rust programs
Diffstat (limited to 'pkgs/development/tools')
5 files changed, 58 insertions, 15 deletions
diff --git a/pkgs/development/tools/build-managers/cargo/common.nix b/pkgs/development/tools/build-managers/cargo/common.nix index f0d8f92dfaa3..d993681b28f8 100644 --- a/pkgs/development/tools/build-managers/cargo/common.nix +++ b/pkgs/development/tools/build-managers/cargo/common.nix @@ -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; } diff --git a/pkgs/development/tools/build-managers/cargo/default.nix b/pkgs/development/tools/build-managers/cargo/default.nix new file mode 100644 index 000000000000..5f21ab1235d3 --- /dev/null +++ b/pkgs/development/tools/build-managers/cargo/default.nix @@ -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} + ''; +} diff --git a/pkgs/development/tools/build-managers/cargo/setup-hook.sh b/pkgs/development/tools/build-managers/cargo/setup-hook.sh new file mode 100644 index 000000000000..91a7f0f5bc8e --- /dev/null +++ b/pkgs/development/tools/build-managers/cargo/setup-hook.sh @@ -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 diff --git a/pkgs/development/tools/build-managers/cargo/snapshot.nix b/pkgs/development/tools/build-managers/cargo/snapshot.nix index 64aeb0736c17..cc950af3f50d 100644 --- a/pkgs/development/tools/build-managers/cargo/snapshot.nix +++ b/pkgs/development/tools/build-managers/cargo/snapshot.nix @@ -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" \ diff --git a/pkgs/development/tools/rust/racer/default.nix b/pkgs/development/tools/rust/racer/default.nix index 341088dc0f2d..c22ee64b7423 100644 --- a/pkgs/development/tools/rust/racer/default.nix +++ b/pkgs/development/tools/rust/racer/default.nix @@ -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 |