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
buildRustPackage, fetchcargo: optionally use the real config from cargo vendor #45889
Conversation
Great!
The only thing which is missing is an update of the documentation |
Maybe even release notes so that we can deprecate the old behavior on 19.03 ? |
Glad you like it! Do you think this could make it into 18.09? I'll try to add documentation in the next few hours. |
Ok, can't work on it earlier than tomorrow. |
41cd1b2
to
163686e
Compare
Changed my commit to include documentation and release notes. |
…-vendor By setting useRealVendorConfig explicitly to true, the actual (slightly modified) config generated by cargo-vendor is used. This solves a problem, where the static vendor config in pkgs/build-support/rust/default.nix would not sufficiently replace all crates Cargo is looking for. As useRealVendorConfig (and writeVendorConfig in fetchcargo) default to false, there should be no breakage in existing cargoSha256 hashes. Nethertheless, imho using this new feature should become standard. A possible deprecation path could be: - introduce this patch - set useRealVendorConfig explicitly to false whereever cargoSha256 is set but migration is not wanted yet. - after some time, let writeVendorConfig default to true - when useRealVendorConfig is true everywhere cargoSha256 is set and enough time is passed, `assert cargoVendorDir == null -> useRealVendorConfig;`, remove old behaviour - after some time, remove all appearences of useRealVendorConfig and the parameter itself
163686e
to
c90de4c
Compare
and rebased to current master... |
EOF | ||
'' + (if useRealVendorConfig then '' | ||
sed "s|directory = \".*\"|directory = \"$(pwd)/$cargoDepsCopy\"|g" \ | ||
"$(pwd)/$cargoDepsCopy/.cargo/config" > .cargo/config |
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.
Not that someone tried this before and there the idea was to enable it by default.
I have a better feeling if we only do this on a subset on packages like this pull request does, since the output of cargo-vendor
can still change in future.
Can you also add a check to read the generated configuration of cargo-vendor
and emits an error if the it contains git repositories but useRealVendorConfig
is not enabled?
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.
The fact, that there are so many prior issues and PRs about this is annoying. I really should've done my research, sorry for that.
Also, the fact that the output of cargo-vendor can change really did not come to my mind. As you say it, it is clear to me that my PR wouldn't be the good solution I was hoping for, but more of a hack.
I wonder if it would be better to close this PR and open another one, as your proposal really changes the direction where this is going?
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.
I think what could work instead is, having a script with a toml parser (e.x.: python), that reads the cargo config and produces cargo config for the fixed-output derivation. That way we can control the output and can enable this by default.
that currently this parameter defaults to `false` only due to compatibility | ||
reasons, as setting this to `true` requires a change in `cargoSha256`. | ||
Eventually this distinction will be deprecated, so please always set | ||
`useRealVendorConfig` to `true` and make sure to recompute the `cargoSha256`. |
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.
For this to become the default I would like to see our own script generating .cargo/config
to avoid breaking checksums. cargo-vendor
's output is not supposed to be stable: https://github.com/NixOS/nixpkgs/pull/34034/files#r162713377
That's why I would not set it by default.
Unfortunately I have near to no time for this atm. Please go ahead, if anyone wants to finish this. |
To repeat my comment so it will not get lost: |
#46362 is a continuation of this. |
Close, as #46362 was merged. Yay! |
Motivation for this change
Current
fetchcargo
behaviour is not sufficient, when sources different from crates.io are used. An example where this makes packaging impossible is #44465.As a naive change of the code would result in breaking
cargoSha256
all over the place, an additional argument is proposed to turn the new behaviour on.Things done
This introduces
useRealVendorConfig
as a new argument tobuildRustPackage
. WheneverbuildRustPackage
fetches Cargo dependencies anduseRealVendorConfig
is true,fetchcargo
writes its generated config into the vendor output.Imho this behaviour should be desirable all the time. A possible migration path is proposed in the commit message.
This should trigger a rebuild in every package using
cargoSha256
.How I tested this
nix-build -A rustracer --check
.cargoSha256
ofrustracer
, rebuilt, still wants the old hash.nix-build -A cargo --check
, a package which usesbuildRustPackage
but notfetchcargo
, same drv as on master.sequoia-pgp
withuseRealVendorConfig = true
, a package with dependencies from non-crates.io sources.Pinging @symphorien @madjar @cstrahan @wizeman @globin @Havvy @wkennington
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)