Skip to content

Commit

Permalink
Merge pull request NixOS#3 from dezren39/patch-2_3
Browse files Browse the repository at this point in the history
  • Loading branch information
dezren39 authored Jul 3, 2024
2 parents 5a9e899 + dcfaa5d commit a6f6b88
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
13 changes: 9 additions & 4 deletions pkgs/by-name/wr/wrangler/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@
npmHooks,
writeScriptBin,
}:

stdenv.mkDerivation (finalAttrs: {
let
srcHash = "sha256-/4iIkvSn85fkRggmIha2kRlW0MEwvzy0ZAmIb8+LpZQ=";
pnpmDepsHash = "sha256-aT1aidXm1WYwmy+ljUC9yO3qtvN20SA+24T83dWYrI0=";
in
stdenv.mkDerivation (finalAttrs: {
pname = "wrangler";
version = "3.62.0";

src = fetchFromGitHub {
owner = "cloudflare";
repo = "workers-sdk";
rev = "wrangler@${finalAttrs.version}";
hash = "sha256-/4iIkvSn85fkRggmIha2kRlW0MEwvzy0ZAmIb8+LpZQ=";
hash = "${srcHash}";
};

nativeBuildInputs = [
Expand All @@ -27,7 +30,7 @@ stdenv.mkDerivation (finalAttrs: {

pnpmDeps = pnpm_9.fetchDeps {
inherit (finalAttrs) pname version src;
hash = "sha256-aTTaiGXm1WYwmy+ljUC9yO3qtvN20SA+24T83dWYrI0=";
hash = "${pnpmDepsHash}";
};

# @cloudflare/vitest-pool-workers wanted to run a server as part of the build process
Expand Down Expand Up @@ -80,6 +83,8 @@ stdenv.mkDerivation (finalAttrs: {
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
14 changes: 10 additions & 4 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 --name "$store_name" "$url")
src_hash=$(nix-hash --to-sri --type sha256 "$sha256")
sed -i 's#hash = "[^"]*"#hash = "'"$src_hash"'"#' package.nix
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 a6f6b88

Please sign in to comment.