From 614a99bd8e20223ed3270d3cbc293cc03c878867 Mon Sep 17 00:00:00 2001 From: "Ricardo M. Correia" Date: Sun, 14 Sep 2014 02:14:48 +0200 Subject: [PATCH] cargoSnapshot: Add package Cargo downloads your Rust project's dependencies and builds your project. The cargoSnapshot derivation simply uses a binary build, because it's not easy to build cargo from source yet. In the future, it's expected that we'll also add a derivation for building cargo from source. --- .../tools/build-managers/cargo/common.nix | 52 +++++++++++++++++++ .../tools/build-managers/cargo/snapshot.nix | 7 +++ pkgs/top-level/all-packages.nix | 2 + 3 files changed, 61 insertions(+) create mode 100644 pkgs/development/tools/build-managers/cargo/common.nix create mode 100644 pkgs/development/tools/build-managers/cargo/snapshot.nix diff --git a/pkgs/development/tools/build-managers/cargo/common.nix b/pkgs/development/tools/build-managers/cargo/common.nix new file mode 100644 index 000000000000..f921a5ac81a8 --- /dev/null +++ b/pkgs/development/tools/build-managers/cargo/common.nix @@ -0,0 +1,52 @@ +{stdenv, fetchurl, zlib}: + +with stdenv.lib; + +rec { + 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 "no snapshot to boostrap for this platform (missing platform url suffix)"; + + snapshotHash = if stdenv.system == "i686-linux" + then "c92895421e6fa170dbd713e74334b8c3cf22b817" + else if stdenv.system == "x86_64-linux" + then "66ee4126f9e4820cd82e78181931f8ea365904de" + else if stdenv.system == "i686-darwin" + then "e2364b1f1ece338b9fc4c308c472fc2413bff04e" + else if stdenv.system == "x86_64-darwin" + then "09f92f06ab4f048acf71d83dc0426ff1509779a9" + else abort "no snapshot for platform ${stdenv.system}"; + + snapshotDate = "2014-09-19"; + snapshotName = "cargo-nightly-${platform}.tar.gz"; + + snapshot = stdenv.mkDerivation { + name = "cargo-snapshot-${snapshotDate}"; + src = fetchurl { + url = "https://static-rust-lang-org.s3.amazonaws.com/cargo-dist/${snapshotDate}/${snapshotName}"; + sha1 = snapshotHash; + }; + dontStrip = true; + installPhase = '' + mkdir -p "$out" + cp -r bin "$out/bin" + '' + (if stdenv.isLinux then '' + patchelf --interpreter "${stdenv.glibc}/lib/${stdenv.gcc.dynamicLinker}" \ + --set-rpath "${stdenv.gcc.gcc}/lib/:${stdenv.gcc.gcc}/lib64/:${zlib}/lib" \ + "$out/bin/cargo" + '' else ""); + }; + + meta = { + homepage = http://crates.io; + description = "Downloads your Rust project's dependencies and builds your project"; + license = [ licenses.mit licenses.asl20 ]; + platforms = platforms.linux; + }; +} diff --git a/pkgs/development/tools/build-managers/cargo/snapshot.nix b/pkgs/development/tools/build-managers/cargo/snapshot.nix new file mode 100644 index 000000000000..c171401153f6 --- /dev/null +++ b/pkgs/development/tools/build-managers/cargo/snapshot.nix @@ -0,0 +1,7 @@ +{ stdenv, fetchurl, zlib }: + +/* Cargo binary snapshot */ + +with ((import ./common.nix) {inherit stdenv fetchurl zlib; }); + +snapshot // meta diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 2a544bb058b7..82b06349a8db 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -4122,6 +4122,8 @@ let byacc = callPackage ../development/tools/parsing/byacc { }; + cargoSnapshot = callPackage ../development/tools/build-managers/cargo/snapshot.nix { }; + casperjs = callPackage ../development/tools/casperjs { }; cbrowser = callPackage ../development/tools/misc/cbrowser { };