https://github.com/NixOS/nixpkgs/issues/138554 (" buildRustPackage breaks with keepBuildTree or in nix-shell") being idle for a year, I made a more general issue https://github.com/NixOS/nixpkgs/issues/189691 (“Use of $NIX_BUILD_TOP considered harmful”) and thought I’d post here for more visibility.
What do you think?
I think buildRustOPackage just needs proper support for
keepBuildTree and I would guess that using relative directories would create the same issue.
$NIX_BUILD_TOP must be used instead of
/build and should be avoided if possible which is not always easy or handy.
In the case of
buildRustPackage this happens in
postPatchHooks though, I think we can rely on
sourceRoot being set correctly (and with that
pwd as well) instead. That’s already done in other places in that hook as well, see
https://github.com/NixOS/nixpkgs/blob/042adf08d1c1886dfbe11603b012f987c60b1148/pkgs/build-support/rust/hooks/cargo-setup-hook.sh#L26. Relative paths are not an issue because we can
realpath when setting the variables.
It does not look like
NIX_BUILD_TOP is required at all, I will be opening a PR fixing this later.
Opened said PR, executing from a
keepBuildTree work fine with it from my testing
12:17PM - 12 Sep 22 UTC
###### Description of changes
This PR fixes a few problems I recently encount
I should’ve targeted staging instead for this. Since I had a few commits in the same PR that didn’t cause any rebuilds, I opened a separate PR to fix the