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
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user