From 794750fce26c78225b47b990c3e0dd6ccced5b05 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Tue, 12 Mar 2019 18:19:10 +0100 Subject: [PATCH 1/3] ngrok-2: Fix URLs and automate --- pkgs/tools/networking/ngrok-2/default.nix | 39 ++++++++++++--------- pkgs/tools/networking/ngrok-2/update | 39 +++++++++++++++++++++ pkgs/tools/networking/ngrok-2/versions.json | 32 +++++++++++++++++ 3 files changed, 94 insertions(+), 16 deletions(-) create mode 100755 pkgs/tools/networking/ngrok-2/update create mode 100644 pkgs/tools/networking/ngrok-2/versions.json diff --git a/pkgs/tools/networking/ngrok-2/default.nix b/pkgs/tools/networking/ngrok-2/default.nix index fdf9067dfee..da598c6fbd5 100644 --- a/pkgs/tools/networking/ngrok-2/default.nix +++ b/pkgs/tools/networking/ngrok-2/default.nix @@ -1,25 +1,32 @@ -{ stdenv, fetchurl, unzip }: +{ stdenv, fetchurl }: with stdenv.lib; -stdenv.mkDerivation rec { - name = "ngrok-${version}"; - version = "2.2.8"; +let versions = builtins.fromJSON (builtins.readFile ./versions.json); + arch = if stdenv.isi686 then "386" + else if stdenv.isx86_64 then "amd64" + else if stdenv.isAarch64 then "arm64" + else if stdenv.isArm then "arm" + 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; - src = if stdenv.isLinux && stdenv.isi686 then fetchurl { - url = "https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-i386.tgz"; - sha256 = "0s5ymlaxrvm13q3mlvfirh74sx60qh56c5sgdma2r7q5qlsq41xg"; - } else if stdenv.isLinux && stdenv.isx86_64 then fetchurl { - url = "https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.tgz"; - sha256 = "1mn9iwgy6xzrjihikwc2k2j59igqmph0cwx17qp0ziap9lp5xxad"; - } else if stdenv.isDarwin then fetchurl { - url = "https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-darwin-386.zip"; - sha256 = "0yfd250b55wcpgqd00rqfaa7a82f35fmybb31q5xwdbgc2i47pbh"; - } else throw "platform ${stdenv.hostPlatform.system} not supported!"; +in +stdenv.mkDerivation { + name = "ngrok-${version}"; + version = "${version}"; + + # run ./update + src = fetchurl { inherit sha256 url; }; sourceRoot = "."; - nativeBuildInputs = optional stdenv.isDarwin unzip; + unpackPhase = "cp $src ngrok"; + + buildPhase = "chmod a+x ngrok"; installPhase = '' install -D ngrok $out/bin/ngrok @@ -32,7 +39,7 @@ stdenv.mkDerivation rec { ''; homepage = https://ngrok.com/; license = licenses.unfree; - platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin" ]; + platforms = [ "i686-linux" "x86_64-linux" "aarch64-linux" "x86_64-darwin" ]; maintainers = [ maintainers.bobvanderlinden ]; }; } diff --git a/pkgs/tools/networking/ngrok-2/update b/pkgs/tools/networking/ngrok-2/update new file mode 100755 index 00000000000..f5d7779a87c --- /dev/null +++ b/pkgs/tools/networking/ngrok-2/update @@ -0,0 +1,39 @@ +#!/usr/bin/env nix-shell +#!nix-shell -p httpie +#!nix-shell -p jq +#!nix-shell -i bash + +set -eu -o pipefail +cd "$(dirname "${BASH_SOURCE[0]}")" + +get_download_info() { + echo '{ "sys": "'"$1-$2"'", "response": ' + 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_goVRodbMVm \ + channel=stable \ + os=$1 \ + goarm= \ + target_version=2.2.8 \ + arch=$2 + + echo "}" +} + +( + echo "[" + get_download_info linux 386 + echo "," + get_download_info linux amd64 + echo "," + get_download_info linux arm + echo "," + get_download_info linux arm64 + # echo "," + # get_download_info darwin 386 + echo "," + get_download_info darwin amd64 + echo "]" +) | jq 'map ({ (.sys): { "sys": .sys, "url": .response.download_url, "sha256": .response.checksum, "version": .response.release.version } }) | add' >versions.json diff --git a/pkgs/tools/networking/ngrok-2/versions.json b/pkgs/tools/networking/ngrok-2/versions.json new file mode 100644 index 00000000000..c1b9617fda7 --- /dev/null +++ b/pkgs/tools/networking/ngrok-2/versions.json @@ -0,0 +1,32 @@ +{ + "linux-386": { + "sys": "linux-386", + "url": "https://bin.equinox.io/a/2yoqc96ESxb/ngrok-2.2.8-linux-386", + "sha256": "bfa30baf1a6e31cc152a39d0db9849dbae0bc9e75b3405d92b60b66d1e6e6a32", + "version": "2.2.8" + }, + "linux-amd64": { + "sys": "linux-amd64", + "url": "https://bin.equinox.io/a/67p452rfRWJ/ngrok-2.2.8-linux-amd64", + "sha256": "a5d0e85f370d66c77c7e850c43e3cc5a09ef24e677ba64c38207c6b00aae4647", + "version": "2.2.8" + }, + "linux-arm": { + "sys": "linux-arm", + "url": "https://bin.equinox.io/a/cxXSbVrW7ue/ngrok-2.2.8-linux-arm", + "sha256": "c34a074bd9c33c7179cdd9e58735c1fdea4e472405608a8b2cb098ad4ca5da69", + "version": "2.2.8" + }, + "linux-arm64": { + "sys": "linux-arm64", + "url": "https://bin.equinox.io/a/dS5TkJ3xTyi/ngrok-2.2.8-linux-arm64", + "sha256": "9d42324a3e9dbddfe3cfd62f5e3334b9e2b4a3650ed6ace8d18e21a026a2acc3", + "version": "2.2.8" + }, + "darwin-amd64": { + "sys": "darwin-amd64", + "url": "https://bin.equinox.io/a/a7g7TTeof5/ngrok-2.2.8-darwin-amd64", + "sha256": "0b16d445db681b0c85c24992c45488ad859b73a5be982863dcd0467eca4459dd", + "version": "2.2.8" + } +} From 859c28dae1bf87eaa95aff94b3100942983b9da8 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Tue, 12 Mar 2019 20:29:35 +0100 Subject: [PATCH 2/3] ngrok-2: Use stable channel --- pkgs/tools/networking/ngrok-2/update | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/tools/networking/ngrok-2/update b/pkgs/tools/networking/ngrok-2/update index f5d7779a87c..62b0c7e545e 100755 --- a/pkgs/tools/networking/ngrok-2/update +++ b/pkgs/tools/networking/ngrok-2/update @@ -16,9 +16,10 @@ get_download_info() { channel=stable \ os=$1 \ goarm= \ - target_version=2.2.8 \ arch=$2 +# target_version=2.2.8 \ + echo "}" } From a45031aa73e4df821310887b85dfddf27d41cc93 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Sun, 17 Mar 2019 23:57:44 +0100 Subject: [PATCH 3/3] ngrok-2: 2.2.8 -> 2.3.18 --- pkgs/tools/networking/ngrok-2/versions.json | 30 ++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/pkgs/tools/networking/ngrok-2/versions.json b/pkgs/tools/networking/ngrok-2/versions.json index c1b9617fda7..3d7aa8a56b6 100644 --- a/pkgs/tools/networking/ngrok-2/versions.json +++ b/pkgs/tools/networking/ngrok-2/versions.json @@ -1,32 +1,32 @@ { "linux-386": { "sys": "linux-386", - "url": "https://bin.equinox.io/a/2yoqc96ESxb/ngrok-2.2.8-linux-386", - "sha256": "bfa30baf1a6e31cc152a39d0db9849dbae0bc9e75b3405d92b60b66d1e6e6a32", - "version": "2.2.8" + "url": "https://bin.equinox.io/a/jqJ2Vvh67gW/ngrok-2.3.18-linux-386", + "sha256": "2bebb8f39a3c19ca03eaf786b97c92876216d2297046e85271478edef2cd6404", + "version": "2.3.18" }, "linux-amd64": { "sys": "linux-amd64", - "url": "https://bin.equinox.io/a/67p452rfRWJ/ngrok-2.2.8-linux-amd64", - "sha256": "a5d0e85f370d66c77c7e850c43e3cc5a09ef24e677ba64c38207c6b00aae4647", - "version": "2.2.8" + "url": "https://bin.equinox.io/a/ik4d9aurG9/ngrok-2.3.18-linux-amd64", + "sha256": "75e19c343a208bf0e2d3b613d2fa3ce67abbf25c04a1d6be670598a4c25c1694", + "version": "2.3.18" }, "linux-arm": { "sys": "linux-arm", - "url": "https://bin.equinox.io/a/cxXSbVrW7ue/ngrok-2.2.8-linux-arm", - "sha256": "c34a074bd9c33c7179cdd9e58735c1fdea4e472405608a8b2cb098ad4ca5da69", - "version": "2.2.8" + "url": "https://bin.equinox.io/a/c2KRZoJ5cb6/ngrok-2.3.18-linux-arm", + "sha256": "af4cdb9f116104921d7fbeeac9124e545a45495b3623b2b46da996400c305d9c", + "version": "2.3.18" }, "linux-arm64": { "sys": "linux-arm64", - "url": "https://bin.equinox.io/a/dS5TkJ3xTyi/ngrok-2.2.8-linux-arm64", - "sha256": "9d42324a3e9dbddfe3cfd62f5e3334b9e2b4a3650ed6ace8d18e21a026a2acc3", - "version": "2.2.8" + "url": "https://bin.equinox.io/a/b2NBP9tpq2E/ngrok-2.3.18-linux-arm64", + "sha256": "9e5fa5b83dc65803291b59867c664085de248a4adb3d415c4dbba1dae90a0aaf", + "version": "2.3.18" }, "darwin-amd64": { "sys": "darwin-amd64", - "url": "https://bin.equinox.io/a/a7g7TTeof5/ngrok-2.2.8-darwin-amd64", - "sha256": "0b16d445db681b0c85c24992c45488ad859b73a5be982863dcd0467eca4459dd", - "version": "2.2.8" + "url": "https://bin.equinox.io/a/879TXbRQQRV/ngrok-2.3.18-darwin-amd64", + "sha256": "abb643bdba7ade5dabd60488b866804d814a41d4d7144fa09e01c9260e93659d", + "version": "2.3.18" } }