1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-20 12:42:24 +00:00

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`.
This commit is contained in:
Ricardo M. Correia 2015-05-29 19:35:31 +02:00
parent 023f0f7992
commit d7ebe7a4f3
3 changed files with 16 additions and 23 deletions

View file

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

View file

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

View file

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