-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rustPlatform.importCargoLock: allow duplicated packages with git. #282798
base: staging
Are you sure you want to change the base?
Conversation
greetings @junjihashimoto this should target staging branch due to mass rebuilds https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#changes-causing-mass-rebuilds beware of commit pitfall when changing target branch https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#rebasing-between-branches-ie-from-master-to-staging |
@kirillrdy Thx! Rebased to staging branch. |
b17a692
to
23aa765
Compare
LGTM. I am able to use this branch to build a rust binary which I couldn't build with |
Interestingly this doesn't solve my issue trying to built qdrant 1.8.4, which contains two "wal 0.1.2"s with different git revs https://github.com/qdrant/qdrant/blob/v1.8.4/Cargo.lock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested with a sui flake that would not compile otherwise.
LGTM
@junjihashimoto can you rebase ? |
Sure! |
I had success with the last version but now it breaks while building postgresql.
|
Is there something we can help with here? Testing or anything |
0808078
to
b3d5702
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are packages that use two different crates from the same git repo with the same gitSha. I don't remember which packages, but I've seen them.
So, in those cases there would be key duplications in the source definitions. (Which, I think, would cause toml parsing errors)
Edit: I was wrong, sorry!
It looks like I don't even remember how the code worked... even though I wrote it :/
Fixed the merge conflict. |
@TomaSajt Please remember the code as I don't think anyone else can review this PR but you. |
Note: I haven't thoughly reviewed the importCargoLock part yet. IMO the git sources should be in git/gitShaRev instead of git-gitShaRev. And maybe when other registries become supported they should also get a registry/registryName subdir Or is this just how cargo vendor --no-merge-sources works? Haven't checked it. Though, we have to be careful with moving things, since some packages assume the vendor directory's structure when patching some dependencies. So maybe, to keep breakages to a minimum, only the git stuff should get their own subdir, and the registry deps should stay in the original base directory, instead of in ./registry. |
Yes.
The original registry structure cannot stay as it does not allow multiple packages with different git-hashes for the same version of the same package. |
Sorry if I wasn't being clear: I meant the registry-based stuff only. The git based stuff should go to a different place, since that's what's clashing. (For the record: I looked at the implementation of |
The registry-based stuff is In this PR, the path is |
Yes, the name doesn't matter currently, since we only support The problem is, that there are packages that edit files inside If we don't want to also fix all of these packages in this PR we may not move files inside I don't know if there are any derivations that try to edit a git-based dependency, but those will 100% be broken by this PR no matter what we do. |
But, since there are so few of these packages, it shouldn't be too hard to fix them. If you want to do the fixing yourself, I recommend not hardcoding |
ln -s "$crate" "$out/$gitdir/$package_name" | ||
fi | ||
else | ||
ln -s "$crate" $out/$(basename "$crate" | cut -c 34-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When is this branch reached?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as the above mkCrate is running, it will never be reached, so it can be deleted.
# This is to handle the case of referencing a package with a relative path. | ||
if [ ! -e "$out/$gitdir/$package_name" ] ; then | ||
ln -s "$crate" "$out/$gitdir/$package_name" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you provide an example when this happens?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for pointing that out. This might not be necessary.
pkgs/build-support/rust/test/import-cargo-lock/git-dependency-rev-with-hash/default.nix
Show resolved
Hide resolved
@@ -31,34 +31,36 @@ def replace_key( | |||
local_dep = table[key] | |||
del local_dep["workspace"] | |||
|
|||
workspace_dep = workspace_manifest[section][key] | |||
|
|||
if section == "dependencies": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you summarize what was fixed in this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There may be cases where there is no value for a key such as "dependencies".
I encountered this when building the sui package.
By the way: merging into a PR branch is not recommended. You should have rebased on top of the revision you want, instead of merging. Since this PR doesn't depend on anything that's currently in staging, I think you should rebase onto the common merge base between master and staging. This way it's easier to test the changes, because you don't have to rebuild everything that's in staging. Here's a way you could do it:
|
2871ba9
to
60fe186
Compare
@@ -29,6 +30,7 @@ rustPlatform.buildRustPackage { | |||
buildInputs = | |||
[ | |||
openssl | |||
zlib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wasn't necessary on Linux, but it seems to be necessary on Darwin.
@TomaSajt |
@TomaSajt Please let me know if there's anything else blocking the approval or if you have any other concerns. |
We should wait for the mass migration PRs to reach master, first. After that, the packages that still use |
Description of changes
Fix these issues(#183344 and #30742).
This patch does the same thing of
cargo-vendor --no-merge-sources
.It puts git sources to 'git-<sha>' directory.
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.