From 8b3e81e45db6705addafc593053934506104187c 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 --- README.md | 1 + nix_update/eval.py | 2 ++ nix_update/update.py | 8 ++++++++ 3 files changed, 11 insertions(+) diff --git a/README.md b/README.md index fab887a..4cbdedf 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ designed to work with nixpkgs but also other package sets. - update buildRustPackage's cargoHash/cargoSha256 and cargoSetupHook's cargoDeps - update buildGoModule's vendorHash/vendorSha256 - update buildNpmPackage's npmDepsHash and npmConfigHook's npmDeps +- update fetchYarnDeps offlineCache output hash - update flake outputs (see `--flake`) - build and run the resulting package (see `--build`, `--run` or `--shell` diff --git a/nix_update/eval.py b/nix_update/eval.py index 1503a4e..66e1008 100644 --- a/nix_update/eval.py +++ b/nix_update/eval.py @@ -53,6 +53,7 @@ class Package: go_modules_old: str | None cargo_deps: str | None npm_deps: str | None + yarn_deps: str | None tests: list[str] has_update_script: bool @@ -157,6 +158,7 @@ def eval_expression( else null; npm_deps = pkg.npmDeps.outputHash or null; + yarn_deps = pkg.offlineCache.outputHash or null; tests = builtins.attrNames (pkg.passthru.tests or {{}}); has_update_script = {has_update_script}; src_homepage = pkg.src.meta.homepage or null; diff --git a/nix_update/update.py b/nix_update/update.py index 41e1dd2..1c80de8 100644 --- a/nix_update/update.py +++ b/nix_update/update.py @@ -257,6 +257,11 @@ def update_npm_deps_hash(opts: Options, filename: str, current_hash: str) -> Non replace_hash(filename, current_hash, target_hash) +def update_yarn_deps_hash(opts: Options, filename: str, current_hash: str) -> None: + target_hash = nix_prefetch(opts, "offlineCache") + replace_hash(filename, current_hash, target_hash) + + def update_version( package: Package, version: str, preference: VersionPreference, version_regex: str ) -> bool: @@ -362,4 +367,7 @@ def update(opts: Options) -> Package: if package.npm_deps: update_npm_deps_hash(opts, package.filename, package.npm_deps) + if package.yarn_deps: + update_yarn_deps_hash(opts, package.filename, package.yarn_deps) + return package