-
-
Notifications
You must be signed in to change notification settings - Fork 13.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.fetchCargoVendor: init #349360
base: master
Are you sure you want to change the base?
Conversation
8f86bba
to
8581797
Compare
|
||
# TODO: support other repositories | ||
# or maybe allow getting downloadUrl through an API request | ||
def download_tarball(args: tuple[dict, str]): |
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.
A TypeDict
would provide more insight on what keys the dictionary has
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
@Mic92 For typing dictionnaries, I proposed to use |
elif method == "create-vendor": | ||
create_vendor(vendor_staging_dir=sys.argv[2], out_dir=sys.argv[3]) | ||
else: | ||
raise Exception(f"Unknown method: {method}") |
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 would make create your own Exception
at the start of the script:
class Error(Exception):
pass
and than catch this exception in the main method:
try:
...
exception Error as e:
eprint(e)
This won't show than error stacktraces for our own errors, which is a bit more user friendly (because users often don't find the relevant error from a stack trace).
fetchCargoVendorUtil | ||
cargo | ||
replaceWorkspaceValues | ||
]; |
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.
Would be nice to also type check this:
]; | |
]; | |
passthru.tests = { | |
typecheckAndLint = runCommand "mypy-check" { nativeBuildInputs = [ mypy ruff ]; } '' | |
mypy ${./.} | |
ruff format --check ${./.} | |
ruff check ${./.} | |
touch $out | |
''; | |
}; |
ok with me. Does typedDict has to include all fields or only the ones we care about? |
If this can replace our vendored cargo.lock files in many pacles, this is a great addition. I hope we can consolidate this and replace our current vendoring. But would be also fine to do this as a second step and incrementally convert our usage to the new fetcher. |
I think we can just use ruff format and ruff check. Pretty much the same thing but also more potential lints and also faster. |
you can set |
Yeah, i suggested black because i've been using it for years ahah, has long has it complies with pep8 i believe it's fine |
ruff format should be almost 100% compatible to black. |
594e710
to
c6fb7f7
Compare
ebde301
to
756989e
Compare
756989e
to
d27382d
Compare
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.
Using this fetcher, we won't have to worry about cargo changing its vendoring implementation, thus we can replace all
importCargoLock
usages 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.gz
and 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.
This staging FOD will 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.Unfortunately, this way the output of this new fetcher will not directly be a FOD.
The FOD itself will be accessible from
cargoDeps.vendorStaging
.TODO: maybe add an easy way to override the FOD inputs.
Currently there is no way to use this through
buildCargoPackage
, since it hard-codes the usage offetchCargoTarball
.Should there be a toggle to use this fetcher?
customFetcher = true;
Maybe an enum?
cargoFetcher = "custom"
vscargoFetcher = "default"
;Maybe just
cargoFetcher = rustPlatform.fetchCargoVendor
The implementation could be easily changed so that the fetcher will not need the entire
src
passed in, only a path to theCargo.lock
. This isn't IFD, since we only need the path. This would be similar to how it's done withfetchYarnDeps
.Though, having it as a normal mkDerivation, like it is now, we can also apply patches and use hooks.
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-git
to 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 it as outputting a directory until the testing is done.
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.