From 662820bc48e1a0b578f0ec0bf1e039592dceb70e Mon Sep 17 00:00:00 2001 From: "imad.nyc" Date: Sun, 3 Mar 2024 16:05:23 -0500 Subject: [PATCH 1/2] maintainers: add imadnyc --- maintainers/maintainer-list.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index e17652ff3fe2..f76ed2121e3b 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -8171,6 +8171,13 @@ github = "ilyakooo0"; githubId = 6209627; }; + imadnyc = { + email = "me@imad.nyc"; + github = "imadnyc"; + githubId = 113966166; + name = "Abdullah Imad"; + matrix = "@dre:imad.nyc"; + }; imalison = { email = "IvanMalison@gmail.com"; github = "colonelpanic8"; From aa9b78da891f522cd8eca0aff3066a2781ae38f0 Mon Sep 17 00:00:00 2001 From: "imad.nyc" Date: Sat, 2 Mar 2024 20:47:40 -0500 Subject: [PATCH 2/2] warp-terminal: added passthru update script --- pkgs/by-name/wa/warp-terminal/package.nix | 15 +++--- pkgs/by-name/wa/warp-terminal/update.sh | 60 +++++++++++++++++++++ pkgs/by-name/wa/warp-terminal/versions.json | 10 ++++ 3 files changed, 79 insertions(+), 6 deletions(-) create mode 100755 pkgs/by-name/wa/warp-terminal/update.sh create mode 100644 pkgs/by-name/wa/warp-terminal/versions.json diff --git a/pkgs/by-name/wa/warp-terminal/package.nix b/pkgs/by-name/wa/warp-terminal/package.nix index e2f0b4d275ef..972afafda567 100644 --- a/pkgs/by-name/wa/warp-terminal/package.nix +++ b/pkgs/by-name/wa/warp-terminal/package.nix @@ -17,13 +17,15 @@ let pname = "warp-terminal"; -version = "0.2024.02.20.08.01.stable_01"; +versions = lib.importJSON ./versions.json; +passthru.updateScript = ./update.sh; linux = stdenv.mkDerivation (finalAttrs: { - inherit pname version meta; + inherit pname meta passthru; + inherit (versions.linux) version; src = fetchurl { + inherit (versions.linux) hash; url = "https://releases.warp.dev/stable/v${finalAttrs.version}/warp-terminal-v${finalAttrs.version}-1-x86_64.pkg.tar.zst"; - hash = "sha256-L8alnqSE4crrDozRfPaAAMkLc+5+8d9XBKd5ddsxmD0="; }; sourceRoot = "."; @@ -65,10 +67,11 @@ linux = stdenv.mkDerivation (finalAttrs: { }); darwin = stdenvNoCC.mkDerivation (finalAttrs: { - inherit pname version meta; + inherit pname meta passthru; + inherit (versions.darwin) version; src = fetchurl { + inherit (versions.darwin) hash; url = "https://releases.warp.dev/stable/v${finalAttrs.version}/Warp.dmg"; - hash = "sha256-tFtoD8URMFfJ3HRkyKStuDStFkoRIV97y9kV4pbDPro="; }; sourceRoot = "."; @@ -90,7 +93,7 @@ meta = with lib; { homepage = "https://www.warp.dev"; license = licenses.unfree; sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; - maintainers = with maintainers; [ emilytrau Enzime ]; + maintainers = with maintainers; [ emilytrau Enzime imadnyc ]; platforms = platforms.darwin ++ [ "x86_64-linux" ]; }; diff --git a/pkgs/by-name/wa/warp-terminal/update.sh b/pkgs/by-name/wa/warp-terminal/update.sh new file mode 100755 index 000000000000..d60e0f1f5aa9 --- /dev/null +++ b/pkgs/by-name/wa/warp-terminal/update.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p curl jq moreutils nix-prefetch +#shellcheck shell=bash +set -eu -o pipefail + +dirname="$(dirname "$0")" + +err() { + echo "$*" >&2 +} + +json_get() { + jq -r "$1" < "$dirname/versions.json" +} + +json_set() { + jq --arg x "$2" "$1 = \$x" < "$dirname/versions.json" | sponge "$dirname/versions.json" +} + +resolve_url() { + local pkg sfx url + local -i i max_redirects + case "$1" in + darwin) + pkg=macos + sfx=dmg + ;; + linux) + pkg=pacman + sfx=pkg.tar.zst + ;; + *) + err "Unexpected download type: $1" + exit 1 + ;; + esac + url="https://app.warp.dev/download?package=${pkg}" + ((max_redirects = 15)) + for ((i = 0; i < max_redirects; i++)); do + url=$(curl -s -o /dev/null -w '%{redirect_url}' "${url}") + [[ ${url} != *.${sfx} ]] || break + done + ((i < max_redirects)) || { err "too many redirects"; exit 1; } + echo "${url}" +} + +get_version() { + echo "$1" | grep -oP -m 1 '(?<=/v)[\d.\w]+(?=/)' +} + +for sys in darwin linux; do + url=$(resolve_url ${sys}) + version=$(get_version "${url}") + if [[ ${version} != "$(json_get ".${sys}.version")" ]]; + then + sri=$(nix hash to-sri --type sha256 "$(nix-prefetch-url --type sha256 "${url}")") + json_set ".${sys}.version" "${version}" + json_set ".${sys}.hash" "${sri}" + fi +done diff --git a/pkgs/by-name/wa/warp-terminal/versions.json b/pkgs/by-name/wa/warp-terminal/versions.json new file mode 100644 index 000000000000..99fdfa65c73f --- /dev/null +++ b/pkgs/by-name/wa/warp-terminal/versions.json @@ -0,0 +1,10 @@ +{ + "darwin" : { + "hash" : "sha256-tFtoD8URMFfJ3HRkyKStuDStFkoRIV97y9kV4pbDPro=", + "version" : "0.2024.02.20.08.01.stable_01" + }, + "linux" : { + "hash" : "sha256-L8alnqSE4crrDozRfPaAAMkLc+5+8d9XBKd5ddsxmD0=", + "version" : "0.2024.02.20.08.01.stable_01" + } +}