Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
dezren39 committed Jul 3, 2024
1 parent 621da82 commit dcfaa5d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion pkgs/by-name/wr/wrangler/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}:
let
srcHash = "sha256-/4iIkvSn85fkRggmIha2kRlW0MEwvzy0ZAmIb8+LpZQ=";
pnpmDepsHash = "sha256-aTTaiGXm1WYwmy+ljUC9yO3qtvN20SA+24T83dWYrI0=";
pnpmDepsHash = "sha256-aT1aidXm1WYwmy+ljUC9yO3qtvN20SA+24T83dWYrI0=";
in
stdenv.mkDerivation (finalAttrs: {
pname = "wrangler";
Expand Down Expand Up @@ -83,6 +83,8 @@ in
substituteInPlace $out/bin/wrangler --replace-warn WRANGLER_PATH $out
'';

passthru.updateScript = ./update.sh;

meta = {
description = "Command-line interface for all things Cloudflare Workers";
homepage = "https://github.com/cloudflare/workers-sdk#readme";
Expand Down
12 changes: 9 additions & 3 deletions pkgs/by-name/wr/wrangler/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@ if [[ "$UPDATE_NIX_OLD_VERSION" == "$version" ]]; then
echo "Already up to date!"
exit 0
fi

sed -i 's#version = "[^"]*"#version = "'"$version"'"#' package.nix

store_name="wrangler_$version.tar.gz"
sha256=$(nix-prefetch-url --quiet --unpack --name "$store_name" "$url")
src_hash=$(nix hash to-sri --type sha256 "$sha256")
prefetched_url=$(nix-prefetch-url --quiet --unpack --name "$store_name" "$url")
src_hash=$(nix hash to-sri --type sha256 "$prefetched_url")
sed -i 's#srcHash = "[^"]*"#srcHash = "'"$src_hash"'"#' package.nix

pnpm_hash=$(nix-build -E "with import <nixpkgs> {}; callPackage ./package.nix {}" 2>&1 | grep "got: " | awk '{print $NF}')
if [[ "${pnpm_hash}" == "" ]]; then
echo "pnpm_hash already up to date!"
exit 0
fi
sed -i 's#pnpmHash = "[^"]*"#pnpmHash = "'"$pnpm_hash"'"#' package.nix

popd

0 comments on commit dcfaa5d

Please sign in to comment.