about summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authorLily Foster <lily@lily.flowers>2023-12-21 19:40:43 -0500
committerLily Foster <lily@lily.flowers>2023-12-21 19:40:43 -0500
commit5a8c65e118c36697efb1fcec3093d915dd68a8ff (patch)
tree743ecf7063b4e33df0066acdcef6328251f135ee /pkgs/build-support
parent54aac082a4d9bb5bbc5c4e899603abfb76a3f6d6 (diff)
downloadnixlib-5a8c65e118c36697efb1fcec3093d915dd68a8ff.tar
nixlib-5a8c65e118c36697efb1fcec3093d915dd68a8ff.tar.gz
nixlib-5a8c65e118c36697efb1fcec3093d915dd68a8ff.tar.bz2
nixlib-5a8c65e118c36697efb1fcec3093d915dd68a8ff.tar.lz
nixlib-5a8c65e118c36697efb1fcec3093d915dd68a8ff.tar.xz
nixlib-5a8c65e118c36697efb1fcec3093d915dd68a8ff.tar.zst
nixlib-5a8c65e118c36697efb1fcec3093d915dd68a8ff.zip
rustPlatform.importCargoLock: fix workspace_root detection
Prior to this change, the `importCargoLock` git dependency builder
assumed that the workspace root that needed to be passed to
`replace-workspace-values` will always be the root directory of the git
repository.

This is not always the case as independent workspace roots may be used
from subdirectories, and packages be referenced via paths. An example of
this is [1], where the `iced` subdirectory is its own independent
workspace, and workspace values for packages within it should be pulled
from the `iced` subdirectory as the workspace root, not from the
top-level of the fetched repository.

[1]: https://github.com/pop-os/libcosmic/blob/b8f1a366dd030b90ed72e50f521e3da1d6a676ce/Cargo.toml
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/rust/import-cargo-lock.nix2
1 files changed, 1 insertions, 1 deletions
diff --git a/pkgs/build-support/rust/import-cargo-lock.nix b/pkgs/build-support/rust/import-cargo-lock.nix
index c17b0e41cca8..e3fe57ef06da 100644
--- a/pkgs/build-support/rust/import-cargo-lock.nix
+++ b/pkgs/build-support/rust/import-cargo-lock.nix
@@ -193,7 +193,7 @@ let
 
         if grep -q workspace "$out/Cargo.toml"; then
           chmod u+w "$out/Cargo.toml"
-          ${replaceWorkspaceValues} "$out/Cargo.toml" "${tree}/Cargo.toml"
+          ${replaceWorkspaceValues} "$out/Cargo.toml" "$(${cargo}/bin/cargo metadata --format-version 1 --no-deps --manifest-path $crateCargoTOML | ${jq}/bin/jq -r .workspace_root)/Cargo.toml"
         fi
 
         # Cargo is happy with empty metadata.