Commit ecdcdeb2 authored by dr56ekgbb's avatar dr56ekgbb
Browse files

waveterm: add update script

parent 9baaaec6
Loading
Loading
Loading
Loading
+23 −19
Original line number Diff line number Diff line
@@ -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 =
    {
  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";
    }
    .${system} or throwSystem;

  src = fetchurl {
    url = "https://github.com/wavetermdev/waveterm/releases/download/v${version}/${suffix}";
    hash =
      {
      };
      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 −0
Original line number Diff line number Diff line
#!/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