Merge pull request #292928 from imadnyc/warp-terminal-initial-linux

warp-terminal: added passthru update script
This commit is contained in:
a-n-n-a-l-e-e 2024-03-03 14:06:48 -08:00 committed by GitHub
commit 34de1a916a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 86 additions and 6 deletions

View file

@ -8231,6 +8231,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";

View file

@ -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" ];
};

View file

@ -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

View file

@ -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"
}
}