mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-26 04:43:09 +03: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 }:
|
||||
{ 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;
|
||||
};
|
||||
|
||||
|
@ -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 }:
|
||||
{ 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";
|
||||
|
Loading…
Reference in New Issue
Block a user