diff --git a/pkgs/build-support/rust/default.nix b/pkgs/build-support/rust/default.nix index da4d69e1c9e..3fdfc0636f9 100644 --- a/pkgs/build-support/rust/default.nix +++ b/pkgs/build-support/rust/default.nix @@ -45,11 +45,17 @@ let # and have vendored deps, check them against the src attr for consistency. validateCargoDeps = cargoSha256 != "unset" && !legacyCargoFetcher; + # Some cargo builds include build hooks that modify their own vendor + # dependencies. This copies the vendor directory into the build tree and makes + # it writable. If we're using a tarball, the unpackFile hook already handles + # this for us automatically. setupVendorDir = if cargoVendorDir == null - then '' + then ('' unpackFile "$cargoDeps" cargoDepsCopy=$(stripHash $cargoDeps) - '' + '' + stdenv.lib.optionalString legacyCargoFetcher '' + chmod -R +w "$cargoDepsCopy" + '') else '' cargoDepsCopy="$sourceRoot/${cargoVendorDir}" '';