From 611438dde769d7766b83e0ed585c6a899d0b737c Mon Sep 17 00:00:00 2001 From: Yureka Date: Fri, 8 Oct 2021 21:20:21 +0200 Subject: [PATCH] support for updating yarn FOD hash For https://github.com/NixOS/nixpkgs/pull/140701 --- nix_update/eval.py | 2 ++ nix_update/update.py | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/nix_update/eval.py b/nix_update/eval.py index 044122b..a9dee49 100644 --- a/nix_update/eval.py +++ b/nix_update/eval.py @@ -29,6 +29,7 @@ class Package: mod_sha256: Optional[str] vendor_sha256: Optional[str] cargo_sha256: Optional[str] + yarn_sha256: Optional[str] tests: List[str] raw_version_position: InitVar[Optional[Dict[str, Any]]] @@ -70,6 +71,7 @@ def eval_expression(import_path: str, attr: str) -> str: mod_sha256 = pkg.modSha256 or null; vendor_sha256 = pkg.vendorSha256 or null; cargo_sha256 = pkg.cargoHash or pkg.cargoSha256 or null; + yarn_sha256 = (pkg.offlineCache or {{}}).outputHash or null; tests = builtins.attrNames (pkg.passthru.tests or {{}}); }})""" diff --git a/nix_update/update.py b/nix_update/update.py index e0337e1..d9b7955 100644 --- a/nix_update/update.py +++ b/nix_update/update.py @@ -109,6 +109,12 @@ def update_cargo_sha256_hash(opts: Options, filename: str, current_hash: str) -> replace_hash(filename, current_hash, target_hash) +def update_yarn_sha256_hash(opts: Options, filename: str, current_hash: str) -> None: + expr = f"{{ sha256 }}: (import {opts.import_path} {disable_check_meta(opts)}).{opts.attribute}.offlineCache.overrideAttrs (_: {{ inherit sha256; }})" + target_hash = nix_prefetch([expr]) + replace_hash(filename, current_hash, target_hash) + + def update_version( package: Package, version: str, preference: VersionPreference, version_regex: str ) -> bool: @@ -160,4 +166,7 @@ def update(opts: Options) -> Package: if package.cargo_sha256: update_cargo_sha256_hash(opts, package.filename, package.cargo_sha256) + if package.yarn_sha256: + update_yarn_sha256_hash(opts, package.filename, package.yarn_sha256) + return package