From a298a03ba6f2759fc9ed7f0e484799f565d44aa6 Mon Sep 17 00:00:00 2001 From: Bob van der Linden Date: Mon, 22 Jul 2024 15:29:32 +0200 Subject: [PATCH] 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 --- pkgs/by-name/ng/ngrok/package.nix | 77 +++++++++++++++++++++++ pkgs/by-name/ng/ngrok/update.sh | 34 ++++++++++ pkgs/by-name/ng/ngrok/versions.json | 38 +++++++++++ pkgs/tools/networking/ngrok/default.nix | 47 -------------- pkgs/tools/networking/ngrok/update.sh | 34 ---------- pkgs/tools/networking/ngrok/versions.json | 38 ----------- pkgs/top-level/all-packages.nix | 2 - 7 files changed, 149 insertions(+), 121 deletions(-) create mode 100644 pkgs/by-name/ng/ngrok/package.nix create mode 100755 pkgs/by-name/ng/ngrok/update.sh create mode 100644 pkgs/by-name/ng/ngrok/versions.json delete mode 100644 pkgs/tools/networking/ngrok/default.nix delete mode 100755 pkgs/tools/networking/ngrok/update.sh delete mode 100644 pkgs/tools/networking/ngrok/versions.json diff --git a/pkgs/by-name/ng/ngrok/package.nix b/pkgs/by-name/ng/ngrok/package.nix new file mode 100644 index 000000000000..daf9da5c8f2f --- /dev/null +++ b/pkgs/by-name/ng/ngrok/package.nix @@ -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"; + }; +} diff --git a/pkgs/by-name/ng/ngrok/update.sh b/pkgs/by-name/ng/ngrok/update.sh new file mode 100755 index 000000000000..60649faf05cb --- /dev/null +++ b/pkgs/by-name/ng/ngrok/update.sh @@ -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 diff --git a/pkgs/by-name/ng/ngrok/versions.json b/pkgs/by-name/ng/ngrok/versions.json new file mode 100644 index 000000000000..a049d26be676 --- /dev/null +++ b/pkgs/by-name/ng/ngrok/versions.json @@ -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" + } +} diff --git a/pkgs/tools/networking/ngrok/default.nix b/pkgs/tools/networking/ngrok/default.nix deleted file mode 100644 index ac5b19ab4c3f..000000000000 --- a/pkgs/tools/networking/ngrok/default.nix +++ /dev/null @@ -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"; - }; -} diff --git a/pkgs/tools/networking/ngrok/update.sh b/pkgs/tools/networking/ngrok/update.sh deleted file mode 100755 index ed2d975bee2f..000000000000 --- a/pkgs/tools/networking/ngrok/update.sh +++ /dev/null @@ -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 diff --git a/pkgs/tools/networking/ngrok/versions.json b/pkgs/tools/networking/ngrok/versions.json deleted file mode 100644 index b9a285a13e55..000000000000 --- a/pkgs/tools/networking/ngrok/versions.json +++ /dev/null @@ -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" - } -} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 343d36b57e36..286e6713c4ca 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -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 { };