add vendorHash

This commit is contained in:
zowoq 2022-09-17 10:11:22 +10:00
parent 9e3ab3c1d8
commit e4de7e6287
3 changed files with 10 additions and 5 deletions

View File

@ -11,7 +11,7 @@ designed to work with nixpkgs but also other package sets.
- pypi
- rubygems.org
- update buildRustPackage's cargoHash/cargoSha256
- update buildGoModule's vendorSha256
- update buildGoModule's vendorHash/vendorSha256
- build and run the resulting package (see `--build`,
`--run` or `--shell`
- commit updated files (see `--commit` flag)

View File

@ -26,6 +26,7 @@ class Package:
url: Optional[str]
rev: str
hash: Optional[str]
vendor_hash: Optional[str]
vendor_sha256: Optional[str]
cargo_deps: Optional[str]
tests: List[str]
@ -66,6 +67,7 @@ def eval_expression(import_path: str, attr: str) -> str:
url = pkg.src.url or null;
rev = pkg.src.rev or null;
hash = pkg.src.outputHash or null;
vendor_hash = pkg.vendorHash or null;
vendor_sha256 = pkg.vendorSha256 or null;
cargo_deps = pkg.cargoHash or pkg.cargoSha256 or null;
tests = builtins.attrNames (pkg.passthru.tests or {{}});

View File

@ -91,8 +91,8 @@ def update_src_hash(opts: Options, filename: str, current_hash: str) -> None:
replace_hash(filename, current_hash, target_hash)
def update_go_vendor_hash(opts: Options, filename: str, current_hash: str) -> None:
expr = f"{{ sha256 }}: (import {opts.import_path} {disable_check_meta(opts)}).{opts.attribute}.go-modules.overrideAttrs (_: {{ vendorSha256 = sha256; }})"
def update_go_modules_hash(opts: Options, filename: str, current_hash: str) -> None:
expr = f"{{ sha256 }}: (import {opts.import_path} {disable_check_meta(opts)}).{opts.attribute}.go-modules.overrideAttrs (_: {{ inherit sha256; }})"
target_hash = nix_prefetch([expr])
replace_hash(filename, current_hash, target_hash)
@ -144,8 +144,11 @@ def update(opts: Options) -> Package:
# if no package.hash was provided we just update the other hashes unconditionally
if update_hash or not package.hash:
if package.vendor_sha256:
update_go_vendor_hash(opts, package.filename, package.vendor_sha256)
if package.vendor_hash and package.vendor_sha256 == "_unset":
update_go_modules_hash(opts, package.filename, package.vendor_hash)
if package.vendor_sha256 and package.vendor_hash == "_unset":
update_go_modules_hash(opts, package.filename, package.vendor_sha256)
if package.cargo_deps:
update_cargo_deps_hash(opts, package.filename, package.cargo_deps)