waveterm: add update script

This commit is contained in:
dr56ekgbb
2024-10-10 05:40:11 +08:00
parent 9baaaec66d
commit ecdcdeb29d
2 changed files with 48 additions and 19 deletions
+23 -19
View File
@@ -29,35 +29,36 @@
wrapGAppsHook3,
udev,
libGL,
gitUpdater,
}:
let
inherit (stdenv.hostPlatform) system;
throwSystem = throw "Unsupported system: ${system}";
pname = "waveterm";
version = "0.8.8";
suffix =
{
x86_64-linux = "waveterm-linux-x64-${version}.zip";
aarch64-linux = "waveterm-linux-arm64-${version}.zip";
x86_64-darwin = "Wave-darwin-universal-${version}.zip ";
aarch64-darwin = "Wave-darwin-arm64-${version}.zip";
}
.${system} or throwSystem;
src = fetchurl {
url = "https://github.com/wavetermdev/waveterm/releases/download/v${version}/${suffix}";
hash =
{
src =
let
inherit (stdenv.hostPlatform) system;
selectSystem = attrs: attrs.${system} or (throw "Unsupported system: ${system}");
suffix = selectSystem {
x86_64-linux = "waveterm-linux-x64-${version}.zip";
aarch64-linux = "waveterm-linux-arm64-${version}.zip";
x86_64-darwin = "Wave-darwin-universal-${version}.zip ";
aarch64-darwin = "Wave-darwin-arm64-${version}.zip";
};
hash = selectSystem {
x86_64-linux = "sha256-hRpJTFVoBQZyJD06FTRbBPj/1DlYlDWPRjJ1IKeK7Cs=";
aarch64-linux = "sha256-T3VqsoHhPYYrAe/dEd0SUH+G4jpHjKpJTrFy8/AgoKI=";
x86_64-darwin = "sha256-UlyNl2Qu59L4hnK8rTeUV30YVD45L7ub5SP8f97aJrw=";
aarch64-darwin = "sha256-cP+z8DQsNBJc3p57xQdGqqq7jvYcRQRIa+P+6kD3eCc=";
}
.${system} or throwSystem;
};
};
in
fetchurl {
url = "https://github.com/wavetermdev/waveterm/releases/download/v${version}/${suffix}";
inherit hash;
};
passthru.updateScript = ./update.sh;
desktopItems = [
(makeDesktopItem {
@@ -112,6 +113,8 @@ let
src
desktopItems
unpackPhase
meta
passthru
;
nativeBuildInputs = [
@@ -172,6 +175,7 @@ let
src
unpackPhase
meta
passthru
;
nativeBuildInputs = [
+25
View File
@@ -0,0 +1,25 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p bash curl coreutils jq common-updater-scripts
latestTag=$(curl https://api.github.com/repos/wavetermdev/waveterm/releases/latest | jq -r ".tag_name")
latestVersion="$(expr "$latestTag" : 'v\(.*\)')"
currentVersion=$(nix-instantiate --eval -E "with import ./. {}; waveterm.version" | tr -d '"')
echo "latest version: $latestVersion"
echo "current version: $currentVersion"
if [[ "$latestVersion" == "$currentVersion" ]]; then
echo "package is up-to-date"
exit 0
fi
for i in \
"x86_64-linux waveterm-linux-x64" \
"aarch64-linux waveterm-linux-arm64" \
"x86_64-darwin Wave-darwin-universal" \
"aarch64-darwin Wave-darwin-arm64"; do
set -- $i
prefetch=$(nix-prefetch-url "https://github.com/wavetermdev/waveterm/releases/download/v$latestVersion/$2-$latestVersion.zip")
hash=$(nix-hash --type sha256 --to-sri $prefetch)
update-source-version waveterm $latestVersion $hash --system=$1 --ignore-same-version
done