pgrok: 1.3.4 -> 1.4.0

https://github.com/pgrok/pgrok/releases/tag/v1.4.0
This commit is contained in:
Marie Ramlow 2023-08-22 19:36:10 +02:00
parent 2ff705ac55
commit 2f57513f3a
No known key found for this signature in database
5 changed files with 6103 additions and 12 deletions

View File

@ -0,0 +1,11 @@
diff --git a/package.json b/package.json
index 35d34c5..82eda74 100644
--- a/package.json
+++ b/package.json
@@ -1,5 +1,6 @@
{
"name": "pgrokd",
+ "version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "tsc && vite build --outDir=../cli/dist --emptyOutDir",

View File

@ -1,22 +1,25 @@
{ lib
, buildGoModule
, callPackage
, fetchFromGitHub
, nix-update-script
}:
buildGoModule rec {
pname = "pgrok";
version = "1.3.4";
let
version = "1.4.0";
src = fetchFromGitHub {
owner = "pgrok";
repo = "pgrok";
rev = "v${version}";
hash = "sha256-lhcaJVIqZK7GnC/Q/+RDxTVFmgTana3vugDHr/SStFE=";
hash = "sha256-2k3XLXmf1Xnx4HvS7sD/aq+78Z4I7uY4djV958n5TX4=";
};
vendorHash = "sha256-UzNx361cg4IDSQGlX5N9AxYZ8cYA0zsF5JF4Fe7efqM=";
web = callPackage ./web.nix { inherit src version; };
in
buildGoModule {
pname = "pgrok";
inherit version src;
outputs = [ "out" "server" ];
vendorHash = "sha256-M0xVHRh9NKPxmUEmx1dDQUZc8aXcdAfHisQAnt72RdY=";
outputs = [ "out" "server" "web" ];
ldflags = [
"-s"
@ -26,11 +29,24 @@ buildGoModule rec {
"-X main.date=unknown"
];
postInstall = ''
moveToOutput bin/pgrokd $server
subPackages = [
"pgrok/pgrok"
"pgrokd/pgrokd"
];
postPatch = ''
# rename packages due to naming conflict
mv pgrok/cli/ pgrok/pgrok/
mv pgrokd/cli/ pgrokd/pgrokd/
cp -r ${web} pgrokd/pgrokd/dist
'';
passthru.updateScript = nix-update-script { };
postInstall = ''
moveToOutput bin/pgrokd $server
cp -r ${web} $web
'';
passthru.updateScript = ./update.sh;
meta = {
description = "Selfhosted TCP/HTTP tunnel, ngrok alternative, written in Go";

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,58 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p nix wget nix-prefetch-github moreutils jq prefetch-npm-deps nodejs
# adapted from https://github.com/NixOS/nixpkgs/blob/f4ffbe5ecb8039816f2dae60526e0a47f65a2b4e/pkgs/servers/memos/update.sh
set -euo pipefail
TARGET_VERSION_REMOTE=$(curl -s https://api.github.com/repos/pgrok/pgrok/releases/latest | jq -r ".tag_name")
TARGET_VERSION=${TARGET_VERSION_REMOTE#v}
if [[ "$UPDATE_NIX_OLD_VERSION" == "$TARGET_VERSION" ]]; then
echo "pgrok is up-to-date: ${UPDATE_NIX_OLD_VERSION}"
exit 0
fi
extractVendorHash() {
original="${1?original hash missing}"
result="$(nix-build -A pgrok.goModules 2>&1 | tail -n3 | grep 'got:' | cut -d: -f2- | xargs echo || true)"
[ -z "$result" ] && { echo "$original"; } || { echo "$result"; }
}
replaceHash() {
old="${1?old hash missing}"
new="${2?new hash missing}"
awk -v OLD="$old" -v NEW="$new" '{
if (i=index($0, OLD)) {
$0 = substr($0, 1, i-1) NEW substr($0, i+length(OLD));
}
print $0;
}' ./pkgs/tools/networking/pgrok/default.nix | sponge ./pkgs/tools/networking/pgrok/default.nix
}
# change version number
sed -e "s/version =.*;/version = \"$TARGET_VERSION\";/g" \
-i ./pkgs/tools/networking/pgrok/default.nix
# update hash
SRC_HASH="$(nix-instantiate --eval -A pgrok.src.outputHash | tr -d '"')"
NEW_HASH="$(nix-prefetch-github pgrok pgrok --rev v$TARGET_VERSION | jq -r .hash)"
replaceHash "$SRC_HASH" "$NEW_HASH"
GO_HASH="$(nix-instantiate --eval -A pgrok.vendorHash | tr -d '"')"
EMPTY_HASH="$(nix-instantiate --eval -A lib.fakeHash | tr -d '"')"
replaceHash "$GO_HASH" "$EMPTY_HASH"
replaceHash "$EMPTY_HASH" "$(extractVendorHash "$GO_HASH")"
# update src yarn lock
SRC_FILE_BASE="https://raw.githubusercontent.com/pgrok/pgrok/v$TARGET_VERSION"
pushd ./pkgs/tools/networking/pgrok
wget -q "$SRC_FILE_BASE/pgrokd/web/package.json"
npm install --package-lock-only
rm package.json*
NPM_HASH=$(prefetch-npm-deps ./package-lock.json)
popd
sed -i -E -e "s#npmDepsHash = \".*\"#npmDepsHash = \"$NPM_HASH\"#" ./pkgs/tools/networking/pgrok/web.nix

View File

@ -0,0 +1,29 @@
{ buildNpmPackage
, src
, version
}:
buildNpmPackage {
name = "pgrok-web";
inherit src version;
sourceRoot = "${src.name}/pgrokd/web";
npmDepsHash = "sha256-f4pDBoG6sTJE3aUknqUvHHpBR9KWo/B4YMrWHkGbvA8=";
# Upstream doesn't have a lockfile
postPatch = ''
cp ${./package-lock.json} ./package-lock.json
substituteInPlace ./package.json \
--replace "../cli/dist" "$out"
'';
patches = [
./add_version_to_package.json.patch
];
dontInstall = true;
dontFixup = true;
NODE_OPTIONS = "--openssl-legacy-provider";
npmPackFlags = [ "--ignore-scripts" ];
}