From d7ebe7a4f3e3d1f4fdd450f8f80a005e6d80e8c5 Mon Sep 17 00:00:00 2001 From: "Ricardo M. Correia" Date: Fri, 29 May 2015 19:35:31 +0200 Subject: [PATCH] buildRustPackage: Accept `srcs` attribute as well Add support for building Rust packages that have multiple sources, i.e., that use the `srcs` and `sourceRoot` attributes instead of just `src`. --- pkgs/build-support/rust/default.nix | 10 ++++++++-- pkgs/build-support/rust/fetch-builder.sh | 17 ----------------- pkgs/build-support/rust/fetchcargo.nix | 12 ++++++++---- 3 files changed, 16 insertions(+), 23 deletions(-) delete mode 100644 pkgs/build-support/rust/fetch-builder.sh diff --git a/pkgs/build-support/rust/default.nix b/pkgs/build-support/rust/default.nix index 87115e392daf..cd19782e6115 100644 --- a/pkgs/build-support/rust/default.nix +++ b/pkgs/build-support/rust/default.nix @@ -1,5 +1,11 @@ { stdenv, cacert, git, rustc, cargo, rustRegistry }: -{ name, src, depsSha256, buildInputs ? [], cargoUpdateHook ? "", ... } @ args: +{ name, depsSha256 +, src ? null +, srcs ? null +, sourceRoot ? null +, buildInputs ? [] +, cargoUpdateHook ? "" +, ... } @ args: let fetchDeps = import ./fetchcargo.nix { @@ -7,7 +13,7 @@ let }; cargoDeps = fetchDeps { - inherit name src cargoUpdateHook; + inherit name src srcs sourceRoot cargoUpdateHook; sha256 = depsSha256; }; diff --git a/pkgs/build-support/rust/fetch-builder.sh b/pkgs/build-support/rust/fetch-builder.sh deleted file mode 100644 index faa17e653289..000000000000 --- a/pkgs/build-support/rust/fetch-builder.sh +++ /dev/null @@ -1,17 +0,0 @@ -source $stdenv/setup - -# cargo-fetch needs to write to Cargo.lock, even to do nothing. We -# create a fake checkout with symlinks and and editable Cargo.lock. -mkdir copy -cd copy -for f in $(ls $src); do - ln -s $src/"$f" . -done -rm Cargo.lock -cp $src/Cargo.lock . -chmod +w Cargo.lock - -$fetcher . $out - -cd .. -rm -rf copy diff --git a/pkgs/build-support/rust/fetchcargo.nix b/pkgs/build-support/rust/fetchcargo.nix index 7ebd02a485d7..575df64c6b29 100644 --- a/pkgs/build-support/rust/fetchcargo.nix +++ b/pkgs/build-support/rust/fetchcargo.nix @@ -1,12 +1,16 @@ { stdenv, cacert, git, rustc, cargo, rustRegistry }: -{ name ? "cargo-deps", src, sha256, cargoUpdateHook ? "" }: +{ name ? "cargo-deps", src, srcs, sourceRoot, sha256, cargoUpdateHook ? "" }: stdenv.mkDerivation { name = "${name}-fetch"; buildInputs = [ rustc cargo git ]; - builder = ./fetch-builder.sh; - fetcher = ./fetch-cargo-deps; - inherit src rustRegistry cargoUpdateHook; + inherit src srcs sourceRoot rustRegistry cargoUpdateHook; + + phases = "unpackPhase installPhase"; + + installPhase = '' + ${./fetch-cargo-deps} . "$out" + ''; outputHashAlgo = "sha256"; outputHashMode = "recursive";