about summary refs log tree commit diff
diff options
context:
space:
mode:
authorStanisław Pitucha <git@viraptor.info>2022-07-04 13:51:51 +1000
committerStanisław Pitucha <git@viraptor.info>2022-10-07 21:16:55 +1100
commitf38a04a4ab5b4c2dbe0cbeb6e16d531f46ffb849 (patch)
tree4a983c0e12c812daf971a72041e280223dc837af
parentcf6b1a9efd99b862d497e384ad802ac74894137c (diff)
reaper: Add update script
-rw-r--r--pkgs/applications/audio/reaper/default.nix7
-rwxr-xr-xpkgs/applications/audio/reaper/updater.sh18
2 files changed, 24 insertions, 1 deletions
diff --git a/pkgs/applications/audio/reaper/default.nix b/pkgs/applications/audio/reaper/default.nix
index 47a50f2a855ab..d0552f2dbd597 100644
--- a/pkgs/applications/audio/reaper/default.nix
+++ b/pkgs/applications/audio/reaper/default.nix
@@ -17,12 +17,15 @@
 , libpulseaudio
 }:
 
+let
+  url_for_platform = version: arch: "https://www.reaper.fm/files/${lib.versions.major version}.x/reaper${builtins.replaceStrings ["."] [""] version}_linux_${arch}.tar.xz";
+in
 stdenv.mkDerivation rec {
   pname = "reaper";
   version = "6.61";
 
   src = fetchurl {
-    url = "https://www.reaper.fm/files/${lib.versions.major version}.x/reaper${builtins.replaceStrings ["."] [""] version}_linux_${stdenv.hostPlatform.qemuArch}.tar.xz";
+    url = url_for_platform version stdenv.hostPlatform.qemuArch;
     hash = {
       x86_64-linux = "sha256-Lp2EVky1+ruc86LdMmvhZIisoYl0OxdkVnN3h/u09IQ=";
       aarch64-linux = "sha256-sPLCMA//xAdWXjY7++R6eLWS56Zi0u+9ju7JlICGvVc=";
@@ -75,6 +78,8 @@ stdenv.mkDerivation rec {
     runHook postInstall
   '';
 
+  passthru.updateScript = ./updater.sh;
+
   meta = with lib; {
     description = "Digital audio workstation";
     homepage = "https://www.reaper.fm/";
diff --git a/pkgs/applications/audio/reaper/updater.sh b/pkgs/applications/audio/reaper/updater.sh
new file mode 100755
index 0000000000000..750bea346bbc3
--- /dev/null
+++ b/pkgs/applications/audio/reaper/updater.sh
@@ -0,0 +1,18 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i bash -p curl common-updater-scripts
+
+set -euo pipefail
+
+reaper_ver=$(curl -Ls https://www.reaper.fm/download.php | grep -o 'Version [0-9]\.[0-9]*' | head -n1 | cut -d' ' -f2)
+
+function set_hash_for_arch() {
+  local arch=$1
+  pkg_hash=$(nix-prefetch-url https://www.reaper.fm/files/${reaper_ver%.*}.x/reaper${reaper_ver/./}_linux_$arch.tar.xz)
+  pkg_hash=$(nix hash to-sri "sha256:$pkg_hash")
+  # reset the version so the second architecture update doesn't get ignored
+  update-source-version reaper 0 "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" --system=$arch-linux
+  update-source-version reaper "${reaper_ver}" "$pkg_hash" --system=$arch-linux
+}
+
+set_hash_for_arch aarch64
+set_hash_for_arch x86_64