From cd6818baf7e3c0b81373ae9f29761e73bbb3551f Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Fri, 30 Sep 2022 21:09:03 +0000 Subject: [PATCH] rustPlatform: forward unpack hooks to cargo fetch Sometimes it's more ergonomic to set up the build environment in hooks, to add to the default behaviour rather than replacing it. It's very surprising that the fetcher works fine with a custom unpackPhase, but not with custom preUnpack or postUnpack. Packages that use preUnpack or postUnpack and Cargo FODs seem to be very rare. I searched Nixpkgs for files containing one of "cargoHash", "cargoDeps", and "cargoSha256", and one of "preUnpack" or "postUnpack", and only found two such packages: python3.pkgs.tokenizers and rustdesk. Neither of their Cargo FOD hashes are affected by this change. So if that's any indication, we're unlikely to be breaking many out-of-tree hashes with these changes either. --- pkgs/build-support/rust/build-rust-package/default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/rust/build-rust-package/default.nix b/pkgs/build-support/rust/build-rust-package/default.nix index 5ba166bae1a39..2c5d4ae100031 100644 --- a/pkgs/build-support/rust/build-rust-package/default.nix +++ b/pkgs/build-support/rust/build-rust-package/default.nix @@ -24,7 +24,9 @@ , src ? null , srcs ? null +, preUnpack ? null , unpackPhase ? null +, postUnpack ? null , cargoPatches ? [] , patches ? [] , sourceRoot ? null @@ -68,7 +70,7 @@ let if cargoVendorDir != null then null else if cargoLock != null then importCargoLock cargoLock else fetchCargoTarball ({ - inherit src srcs sourceRoot unpackPhase cargoUpdateHook; + inherit src srcs sourceRoot preUnpack unpackPhase postUnpack cargoUpdateHook; name = cargoDepsName; patches = cargoPatches; } // lib.optionalAttrs (args ? cargoHash) {