Repository navigation
rustplatform.cargoSetupHook: force common system libs - #537108
GrimmTheShrimp merged 26 commits into
Conversation
83d32b8 to
4d064d2
Compare
4d064d2 to
ee1be6d
Compare
|
Looks like we do not document the hook variables anywhere, that is unfortunate. |
Review dismissed automatically
|
I think my only concern is dealing with the fallout. I might try and do some form of spot check of major non-leaf packages that blow up because of this. |
|
Yeah will need a coordinated move to merge |
|
a few ones from nix-init's list
this is gonna break a lot of things, we should probably check the lock files (or let cargo resolve the features to reduce false positives) and add the missing dependencies automatically, which should cover most of the use cases |
|
That would be IFD. Edit: Oh, unless you mean as an automated treewide? |
|
I’m kind of fine with letting leaf packages break if we do cleanups during the cycle for popular stuff and just let maintainers pick up the rest as it trickles down to unstable. |
yeah, kinda like when we did the treewide hash update |
ee1be6d to
fe4989b
Compare
|
Went through the defaultCrateOverrides for crate2nix and added their info. Most are just adding libs that the build will fail without, some were not. |
fe4989b to
69a853b
Compare
|
Is there any actual interest in this PR? I can organize merging it to staging, but I'm not going to even try if I have to fight the whole way. |
It def would be a nice to have for me personally |
I am def. interested in this and am more than willing to help with the breakage fallout. |
|
Okay, that's two + one more on Matrix volunteering. I'll see if I can test this properly. I was able to build an ISO with this PR, next I'd like to find a package that fails with this PR to make sure it actually does the one thing it should do. Don't expect too much this week or next as I am currently engrossed in a video game. But I will get to it. |
Why? Just curious |
|
No matter what happens, the crate will link to aws-lc and the others. The difference is that before this patch it will statically link to a pinned vendored version that is downloaded with the crate. This means that if zstd, aws-lc, or the others have a security vulnerability, the crate will continue using the pinned version from several months or years ago. This changes it to link to our libraries that are updated. |
there are a couple reasons, but the single most prominent one is that it allows us to centralize handling of updates. if every package vendored its own copy of a critical package like zlib, when a security update to zlib is released (like happened just last week!), we now have to track down every version of zlib in every package and update it (hint: this won't happen. we don't have the manpower or the tooling for that). in rust packages, that means either convincing upstreams to cut a release or patch lockfiles ourselves. it's much, much easier for us update zlib in one (1) place, and have that immediately benefit every other package in nixpkgs. you also get some smaller benefits, like avoiding building a copy of zlib in every separate package or gaining e.g. performance improvements when upstreams cut a new release. it also sort of ties into the same reason nixpkgs is "one thing", as opposed to separate distributions for each individual package. we generally aim to provide a cohesive package set where everything uses our versions of packages, and we tie them together so that we can handle them all centrally. the usage of every package vendoring its own lockfiles and pinned rust dependencies is actually a compromise here for the sake of practicality; if we were to use the typical system dependency model, we'd ship every rust crate as part of nixpkgs and update them separately. that's not really viable right now, but for system libraries, nixpkgs is really good at shipping those (given, you know, it's our entire job), and so it makes sense to do it for those. |
|
It also allows overlays to affect packages that would otherwise not be affected. For example, I have a bunch of VLC patches that fix bluetooth headphone playback being out of tune and a few other minor annoyances. I don't have to use VLC to get the benefit of that, any other libvlc-based player benefits from those patches. However, if a rust package vendored its own libvlc, it would still have the 'bluetooth headphones play N cents sharp depending on the file type' bug and drive me bananas. It also helps make it clear what dependencies a package actually uses, for e.g. when auditing the dependency graph of a package. Finally, for dynamically linked packages, it saves a little bit of disk space by not duplicating the library contents inside the binary. |
Things done
We want to use system libraries as often as possible. This forces certain common libraries to fail to build if in the tree, and not using system libraries. This is done by setting environement variables that either:
The first is generally easy, as probing usually occurs via
pkg-config, so you just do the same thing as any other package: add pkg-config tonativeBuildInputs, then add your library tobuildInputs.The second is slightly weirder as it is ad-hoc per Rust crate. You need to set vars for lib/include/src for each package in the environment with whatever variable it wants.
I selected the libraries by going on crates.io, searching "-sys", and going through the first few pages.
I will add a release note before merging as I don't really want to deal with release-notes through the review cycle.
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.