Merge pull request #44981 from Ekleog/rust-patch-bis
buildRustPackage: allow patches to fix Cargo.lock
This commit is contained in:
commit
78777fbd6b
|
@ -59,6 +59,11 @@ all crate sources of this package. Currently it is obtained by inserting a
|
||||||
fake checksum into the expression and building the package once. The correct
|
fake checksum into the expression and building the package once. The correct
|
||||||
checksum can be then take from the failed build.
|
checksum can be then take from the failed build.
|
||||||
|
|
||||||
|
When the `Cargo.lock`, provided by upstream, is not in sync with the
|
||||||
|
`Cargo.toml`, it is possible to use `cargoPatches` to update it. All patches
|
||||||
|
added in `cargoPatches` will also be prepended to the patches in `patches` at
|
||||||
|
build-time.
|
||||||
|
|
||||||
To install crates with nix there is also an experimental project called
|
To install crates with nix there is also an experimental project called
|
||||||
[nixcrates](https://github.com/fractalide/nixcrates).
|
[nixcrates](https://github.com/fractalide/nixcrates).
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@ in
|
||||||
{ name, cargoSha256 ? "unset"
|
{ name, cargoSha256 ? "unset"
|
||||||
, src ? null
|
, src ? null
|
||||||
, srcs ? null
|
, srcs ? null
|
||||||
|
, cargoPatches ? []
|
||||||
|
, patches ? []
|
||||||
, sourceRoot ? null
|
, sourceRoot ? null
|
||||||
, logLevel ? ""
|
, logLevel ? ""
|
||||||
, buildInputs ? []
|
, buildInputs ? []
|
||||||
|
@ -23,6 +25,7 @@ let
|
||||||
cargoDeps = if cargoVendorDir == null
|
cargoDeps = if cargoVendorDir == null
|
||||||
then fetchcargo {
|
then fetchcargo {
|
||||||
inherit name src srcs sourceRoot cargoUpdateHook;
|
inherit name src srcs sourceRoot cargoUpdateHook;
|
||||||
|
patches = cargoPatches;
|
||||||
sha256 = cargoSha256;
|
sha256 = cargoSha256;
|
||||||
}
|
}
|
||||||
else null;
|
else null;
|
||||||
|
@ -44,6 +47,8 @@ in stdenv.mkDerivation (args // {
|
||||||
|
|
||||||
buildInputs = [ cacert git rust.cargo rust.rustc ] ++ buildInputs;
|
buildInputs = [ cacert git rust.cargo rust.rustc ] ++ buildInputs;
|
||||||
|
|
||||||
|
patches = cargoPatches ++ patches;
|
||||||
|
|
||||||
configurePhase = args.configurePhase or ''
|
configurePhase = args.configurePhase or ''
|
||||||
runHook preConfigure
|
runHook preConfigure
|
||||||
# noop
|
# noop
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
{ stdenv, cacert, git, rust, cargo-vendor }:
|
{ stdenv, cacert, git, rust, cargo-vendor }:
|
||||||
{ name ? "cargo-deps", src, srcs, sourceRoot, sha256, cargoUpdateHook ? "" }:
|
{ name ? "cargo-deps", src, srcs, patches, sourceRoot, sha256, cargoUpdateHook ? "" }:
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "${name}-vendor";
|
name = "${name}-vendor";
|
||||||
nativeBuildInputs = [ cacert cargo-vendor git rust.cargo ];
|
nativeBuildInputs = [ cacert cargo-vendor git rust.cargo ];
|
||||||
inherit src srcs sourceRoot;
|
inherit src srcs patches sourceRoot;
|
||||||
|
|
||||||
phases = "unpackPhase installPhase";
|
phases = "unpackPhase patchPhase installPhase";
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
if [[ ! -f Cargo.lock ]]; then
|
if [[ ! -f Cargo.lock ]]; then
|
||||||
|
|
Loading…
Reference in a new issue