rustPlatform.fetchCargoVendor: init#349360
Conversation
8f86bba to
8581797
Compare
143eb2c to
eac2cca
Compare
eac2cca to
06035ed
Compare
06035ed to
e4ece40
Compare
e4ece40 to
440b366
Compare
440b366 to
ca03b0b
Compare
|
@ofborg build granian popsicle |
|
I wonder why ofborg is failing... |
6533da7 to
260c771
Compare
|
@ofborg build granian popsicle |
260c771 to
d3d5f70
Compare
I see. That's reasonable but I also think unpacking a tarball is hard to get wrong. (If you remember the command)
Indeed. Given that it has more pressing issues, I don't think we should place much importance on it for sustainable use within Nixpkgs.
You are right of course. This is merely a low-hanging fruit optimisation beyond the status quo. I'll open a separate issue to discuss optimisations for |
|
Successfully created backport PR for |
|
Making a backport as this is going to prevent a lot of other backports from going through, and shouldn't be a breaking change in any way. It can also lead to some nasty surprises on stable, as only setting |
|
I created #377558 to track the support of other registries. |
Related: #327063
This PR adds an alternative method to vendor the dependencies of a cargo project.
It's currently implemented in python, but could be changed later, if need be.
I converted some packages to use this fetcher as an example.
If you can come up with a good name for this fetcher, please share it below.
If we use this fetcher we won't have to worry about cargo changing its vendoring implementation (since this is completely custom), thus we can replace all
importCargoLockusages where it was only required because of the presence of git dependencies.The main idea is that we try to create a minimal staging FOD.
We fetch the tarballs into
$out/tarballs/${name}-${version}.tar.gzand we fetch the git repos to$out/git/${git_sha_rev}.This is the most important part to get right, since we will only be able to minimally change this in the future.
We would still be able to add some extra behaviours in cases that currently just throw an error (e.g. fetching other registries).
The staging FOD will then be used to create the actual vendor dir.
Since this no longer requires network access, we can freely change the implementation of this part without worrying about that hash.
The cargo workspace inheritance logic was already reimplemented by a script written for
importCargoLock, so I just reused that.Since this is a two-step process and only the first step is a FOD, we won't have
outputHashand friends on the result. If we want to override theoutputHash, we would have to do so through thevendorStagingattribute.TODO: it might be useful to add an easier way to override the
outputHashofvendorStaging.I added a commit that makes
buildCargoPackageswap over to this new fetcher implementation. This is currently done through a boolean flag.Should it maybe be an enum instead? e.g.
cargoFetcher = "custom"vscargoFetcher = "default";Sidenote:
The current vendoring script only requires the
Cargo.lockfile and nothing else. This would mean thatfetchCargoVendormay easily be changed to not take insrcand friends, but only a path to the cargo lock, like${src}/Cargo.lock. This is not IFD, since we never import the path from nix, only from a script. This would be similar to how it's done withfetchYarnDeps.Having it as a normal mkDerivation, like it is now, we can also apply patches and use hooks, which might be preferred.
It would be possible to skip the staging phase and make the vendor dir the FOD, however, this would lock our output format to never be able to change again.
The current implementation uses
nix-prefetch-gitto fetch a reproducible git tree, as I wanted to make sure I didn't make any implementation mistakes. I wonder if there's a better method than this...Nothing is stopping us from also compressing the final vendor directory into a tarball, just like with
fetchCargoTarball.Tarballs - obviously - take up less space, so ideally we would do this.
Though a better fetcher name might be needed in that case.
I'm keeping the output as a directory for now, until the testing is done.
I also worry about the fact that non-FOD derivations will rebuild whenever the inputs change. This would mean that whenever
pythonneeds to be rebuilt, every vendor directory created by this would also need to be rebuilt. The rebuilds of the vendor directories would not take much time, but the used up space would be a concern.It would be great if we could tell hydra not to cache certain derivations.
Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-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.