mirror of
https://github.com/SebastianWendel/nixpkgs.git
synced 2024-09-22 05:19:00 +02: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:
parent
023f0f7992
commit
d7ebe7a4f3
|
@ -1,5 +1,11 @@
|
||||||
{ stdenv, cacert, git, rustc, cargo, rustRegistry }:
|
{ stdenv, cacert, git, rustc, cargo, rustRegistry }:
|
||||||
{ name, src, depsSha256, buildInputs ? [], cargoUpdateHook ? "", ... } @ args:
|
{ name, depsSha256
|
||||||
|
, src ? null
|
||||||
|
, srcs ? null
|
||||||
|
, sourceRoot ? null
|
||||||
|
, buildInputs ? []
|
||||||
|
, cargoUpdateHook ? ""
|
||||||
|
, ... } @ args:
|
||||||
|
|
||||||
let
|
let
|
||||||
fetchDeps = import ./fetchcargo.nix {
|
fetchDeps = import ./fetchcargo.nix {
|
||||||
|
@ -7,7 +13,7 @@ let
|
||||||
};
|
};
|
||||||
|
|
||||||
cargoDeps = fetchDeps {
|
cargoDeps = fetchDeps {
|
||||||
inherit name src cargoUpdateHook;
|
inherit name src srcs sourceRoot cargoUpdateHook;
|
||||||
sha256 = depsSha256;
|
sha256 = depsSha256;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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
|
|
|
@ -1,12 +1,16 @@
|
||||||
{ stdenv, cacert, git, rustc, cargo, rustRegistry }:
|
{ stdenv, cacert, git, rustc, cargo, rustRegistry }:
|
||||||
{ name ? "cargo-deps", src, sha256, cargoUpdateHook ? "" }:
|
{ name ? "cargo-deps", src, srcs, sourceRoot, sha256, cargoUpdateHook ? "" }:
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "${name}-fetch";
|
name = "${name}-fetch";
|
||||||
buildInputs = [ rustc cargo git ];
|
buildInputs = [ rustc cargo git ];
|
||||||
builder = ./fetch-builder.sh;
|
inherit src srcs sourceRoot rustRegistry cargoUpdateHook;
|
||||||
fetcher = ./fetch-cargo-deps;
|
|
||||||
inherit src rustRegistry cargoUpdateHook;
|
phases = "unpackPhase installPhase";
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
${./fetch-cargo-deps} . "$out"
|
||||||
|
'';
|
||||||
|
|
||||||
outputHashAlgo = "sha256";
|
outputHashAlgo = "sha256";
|
||||||
outputHashMode = "recursive";
|
outputHashMode = "recursive";
|
||||||
|
|
Loading…
Reference in a new issue