ngrok: 3.10.1 -> 3.13.0 (#328897)

* ngrok: move to pkgs/by-name

* ngrok: support phase hooks

* ngrok: reuse lib.platforms.unix

* ngrok: format using nixfmt-rfc-style

* ngrok: add downloadPage and changelog

* ngrok: remove nested `with lib`

* ngrok: use xh instead of httpie for updateScript

Currently httpie cannot validate HTTPS certificate due to
https://github.com/NixOS/nixpkgs/issues/94666. xh is an alternative
where this problem does not exist.

* ngrok: 3.10.1 -> 3.13.0

* ngrok: format update.sh

* ngrok: use BASH_SOURCE in update.sh

* ngrok: strip on non-darwin systems
This commit is contained in:
Bob van der Linden 2024-07-22 15:29:32 +02:00 committed by GitHub
parent d51dad7c77
commit a298a03ba6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 149 additions and 121 deletions

View File

@ -0,0 +1,77 @@
{
lib,
stdenv,
fetchurl,
}:
let
versions = lib.importJSON ./versions.json;
arch =
if stdenv.isi686 then
"386"
else if stdenv.isx86_64 then
"amd64"
else if stdenv.isAarch32 then
"arm"
else if stdenv.isAarch64 then
"arm64"
else
throw "Unsupported architecture";
os =
if stdenv.isLinux then
"linux"
else if stdenv.isDarwin then
"darwin"
else
throw "Unsupported os";
versionInfo = versions."${os}-${arch}";
inherit (versionInfo) version sha256 url;
in
stdenv.mkDerivation {
pname = "ngrok";
inherit version;
# run ./update
src = fetchurl { inherit sha256 url; };
sourceRoot = ".";
unpackPhase = ''
runHook preUnpack
cp $src ngrok
runHook postUnpack
'';
buildPhase = ''
runHook preBuild
chmod a+x ngrok
runHook postBuild
'';
installPhase = ''
runHook preInstall
install -D ngrok $out/bin/ngrok
runHook postInstall
'';
passthru.updateScript = ./update.sh;
# Stripping causes SEGFAULT on darwin
dontStrip = stdenv.isDarwin;
meta = {
description = "Allows you to expose a web server running on your local machine to the internet";
homepage = "https://ngrok.com/";
downloadPage = "https://ngrok.com/download";
changelog = "https://ngrok.com/docs/agent/changelog/";
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
license = lib.licenses.unfree;
platforms = lib.platforms.unix;
maintainers = with lib.maintainers; [
bobvanderlinden
brodes
];
mainProgram = "ngrok";
};
}

34
pkgs/by-name/ng/ngrok/update.sh Executable file
View File

@ -0,0 +1,34 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p jq xh
set -eu -o pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"
get_download_info() {
xh --json \
https://update.equinox.io/check \
'Accept:application/json; q=1; version=1; charset=utf-8' \
'Content-Type:application/json; charset=utf-8' \
app_id=app_c3U4eZcDbjV \
channel=stable \
os="$1" \
goarm= \
arch="$2" |
jq --arg sys "$1-$2" '{
sys: $sys,
url: .download_url,
sha256: .checksum,
version: .release.version
}'
}
(
get_download_info linux 386
get_download_info linux amd64
get_download_info linux arm
get_download_info linux arm64
get_download_info darwin amd64
get_download_info darwin arm64
) | jq --slurp 'map ({ (.sys): . }) | add' \
>versions.json

View File

@ -0,0 +1,38 @@
{
"linux-386": {
"sys": "linux-386",
"url": "https://bin.equinox.io/a/cYxmmhtKymA/ngrok-v3-3.13.0-linux-386",
"sha256": "f434e84e1e7a37aa9f35d9f3b6a1b3cb36374efbfc309fe2819e36608157ed90",
"version": "3.13.0"
},
"linux-amd64": {
"sys": "linux-amd64",
"url": "https://bin.equinox.io/a/cL3Y3magKAa/ngrok-v3-3.13.0-linux-amd64",
"sha256": "cff5ff71db0191b8fcea1acdbbec70cd2cae57c670343161a9c10761d95a102e",
"version": "3.13.0"
},
"linux-arm": {
"sys": "linux-arm",
"url": "https://bin.equinox.io/a/bsi3rM6xj2X/ngrok-v3-3.13.0-linux-arm",
"sha256": "5d82d847795ad85f0b7d8768e5f6fb8cd8668fc58e4f1434de4601b4e6c920af",
"version": "3.13.0"
},
"linux-arm64": {
"sys": "linux-arm64",
"url": "https://bin.equinox.io/a/isHcV5N1inu/ngrok-v3-3.13.0-linux-arm64",
"sha256": "cc827724c59fe508cec6f8b16a22dba5c06171acadc224034679f9cc34b13c03",
"version": "3.13.0"
},
"darwin-amd64": {
"sys": "darwin-amd64",
"url": "https://bin.equinox.io/a/bYybffm9EV8/ngrok-v3-3.13.0-darwin-amd64",
"sha256": "e03fff765e0af568f4131ccf3abe5c5f93fc3b0ebad5a10e115c8012cdb1482b",
"version": "3.13.0"
},
"darwin-arm64": {
"sys": "darwin-arm64",
"url": "https://bin.equinox.io/a/2w7pzTmD25A/ngrok-v3-3.13.0-darwin-arm64",
"sha256": "aa03fec3b1c111c799d0f5be95a80325ad08448a928b3985fa8a27578cf4b883",
"version": "3.13.0"
}
}

View File

@ -1,47 +0,0 @@
{ lib, stdenv, fetchurl }:
let versions = lib.importJSON ./versions.json;
arch = if stdenv.isi686 then "386"
else if stdenv.isx86_64 then "amd64"
else if stdenv.isAarch32 then "arm"
else if stdenv.isAarch64 then "arm64"
else throw "Unsupported architecture";
os = if stdenv.isLinux then "linux"
else if stdenv.isDarwin then "darwin"
else throw "Unsupported os";
versionInfo = versions."${os}-${arch}";
inherit (versionInfo) version sha256 url;
in
stdenv.mkDerivation {
pname = "ngrok";
inherit version;
# run ./update
src = fetchurl { inherit sha256 url; };
sourceRoot = ".";
unpackPhase = "cp $src ngrok";
buildPhase = "chmod a+x ngrok";
installPhase = ''
install -D ngrok $out/bin/ngrok
'';
passthru.updateScript = ./update.sh;
# Stripping causes SEGFAULT on x86_64-darwin
dontStrip = true;
meta = with lib; {
description = "Allows you to expose a web server running on your local machine to the internet";
homepage = "https://ngrok.com/";
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
license = licenses.unfree;
platforms = [ "i686-linux" "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
maintainers = with maintainers; [ bobvanderlinden brodes ];
mainProgram = "ngrok";
};
}

View File

@ -1,34 +0,0 @@
#!/usr/bin/env nix-shell
#!nix-shell -p httpie
#!nix-shell -p jq
#!nix-shell -i bash
set -eu -o pipefail
get_download_info() {
http --body \
https://update.equinox.io/check \
'Accept:application/json; q=1; version=1; charset=utf-8' \
'Content-Type:application/json; charset=utf-8' \
app_id=app_c3U4eZcDbjV \
channel=stable \
os=$1 \
goarm= \
arch=$2 \
| jq --arg sys "$1-$2" '{
sys: $sys,
url: .download_url,
sha256: .checksum,
version: .release.version
}'
}
(
get_download_info linux 386
get_download_info linux amd64
get_download_info linux arm
get_download_info linux arm64
get_download_info darwin amd64
get_download_info darwin arm64
) | jq --slurp 'map ({ (.sys): . }) | add' \
> pkgs/tools/networking/ngrok/versions.json

View File

@ -1,38 +0,0 @@
{
"linux-386": {
"sys": "linux-386",
"url": "https://bin.equinox.io/a/9uULeng4k9u/ngrok-v3-3.10.1-linux-386",
"sha256": "806700e4c1aa5d6cb10d2ef1ed8079a2e2e8e6d1198f313b0df389589356fcf7",
"version": "3.10.1"
},
"linux-amd64": {
"sys": "linux-amd64",
"url": "https://bin.equinox.io/a/81d5kzodW8G/ngrok-v3-3.10.1-linux-amd64",
"sha256": "d23ed659469e6f58ed0c34bdbc9846744df908c960f1b1e576cf147345f5e833",
"version": "3.10.1"
},
"linux-arm": {
"sys": "linux-arm",
"url": "https://bin.equinox.io/a/8iFd8QPGgx1/ngrok-v3-3.10.1-linux-arm",
"sha256": "36dd1a3893552218f21e118902ae3dabbc43a7f2de1d78937e304893d970377b",
"version": "3.10.1"
},
"linux-arm64": {
"sys": "linux-arm64",
"url": "https://bin.equinox.io/a/c2kv1gi2bti/ngrok-v3-3.10.1-linux-arm64",
"sha256": "86ecd3f4e43c1631a8332a9ee7d629073a7d7bf7412d2d60e1f390f7b2d30bc1",
"version": "3.10.1"
},
"darwin-amd64": {
"sys": "darwin-amd64",
"url": "https://bin.equinox.io/a/44qfe6kGiDc/ngrok-v3-3.10.1-darwin-amd64",
"sha256": "fb0676289962f1310d8902e9c42d2d2ad1d653138e00490209bd422471888429",
"version": "3.10.1"
},
"darwin-arm64": {
"sys": "darwin-arm64",
"url": "https://bin.equinox.io/a/9EoBqwofoME/ngrok-v3-3.10.1-darwin-arm64",
"sha256": "8cee685b259bf32088acee05d6388b912fb10a8e3ba5d99569066ebdad5d5a6f",
"version": "3.10.1"
}
}

View File

@ -10771,8 +10771,6 @@ with pkgs;
ngrep = callPackage ../tools/networking/ngrep { };
ngrok = callPackage ../tools/networking/ngrok { };
nifi = callPackage ../servers/web-apps/nifi { };
noip = callPackage ../tools/networking/noip { };