diff --git a/pkgs/build-support/rust/default-crate-overrides.nix b/pkgs/build-support/rust/default-crate-overrides.nix index 1aebfe60a8d2..126be2ad99eb 100644 --- a/pkgs/build-support/rust/default-crate-overrides.nix +++ b/pkgs/build-support/rust/default-crate-overrides.nix @@ -43,6 +43,7 @@ , udev , webkitgtk_4_1 , zlib +, buildPackages , ... }: @@ -357,4 +358,15 @@ in buildInputs = [ atk ]; }; + # Assumes it can run Command::new(env::var("CARGO")).arg("locate-project") + # https://github.com/bkchr/proc-macro-crate/blame/master/src/lib.rs#L244 + proc-macro-crate = attrs: lib.optionalAttrs (lib.versionAtLeast attrs.version "2.0") { + prePatch = (attrs.prePatch or "") + '' + substituteInPlace \ + src/lib.rs \ + --replace-fail \ + 'env::var("CARGO").map_err(|_| Error::CargoEnvVariableNotSet)?' \ + '"${lib.getBin buildPackages.cargo}/bin/cargo"' + ''; + }; }