From 5a8c65e118c36697efb1fcec3093d915dd68a8ff Mon Sep 17 00:00:00 2001 From: Lily Foster Date: Thu, 21 Dec 2023 19:40:43 -0500 Subject: [PATCH] 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 --- pkgs/build-support/rust/import-cargo-lock.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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.