summary refs log tree commit diff
path: root/pkgs/applications
diff options
context:
space:
mode:
authorAdam Stephens <adam@valkor.net>2023-04-05 18:46:07 -0400
committerAdam Stephens <adam@valkor.net>2023-04-05 22:46:57 -0400
commit84c63f9e2f012ef403552c0fa61830a98f53b0bc (patch)
treec242ed530e1aaab3753117fc2928e70fc7ea62d6 /pkgs/applications
parentda7761cacab07eeb08eb69e94063397e8887404e (diff)
downloadnixpkgs-84c63f9e2f012ef403552c0fa61830a98f53b0bc.tar
nixpkgs-84c63f9e2f012ef403552c0fa61830a98f53b0bc.tar.gz
nixpkgs-84c63f9e2f012ef403552c0fa61830a98f53b0bc.tar.bz2
nixpkgs-84c63f9e2f012ef403552c0fa61830a98f53b0bc.tar.lz
nixpkgs-84c63f9e2f012ef403552c0fa61830a98f53b0bc.tar.xz
nixpkgs-84c63f9e2f012ef403552c0fa61830a98f53b0bc.tar.zst
nixpkgs-84c63f9e2f012ef403552c0fa61830a98f53b0bc.zip
squeezelite: add passthru.updateScript
Diffstat (limited to 'pkgs/applications')
-rw-r--r--pkgs/applications/audio/squeezelite/default.nix2
-rwxr-xr-xpkgs/applications/audio/squeezelite/update.sh19
2 files changed, 21 insertions, 0 deletions
diff --git a/pkgs/applications/audio/squeezelite/default.nix b/pkgs/applications/audio/squeezelite/default.nix
index fa63fee8006..ff85f7e897d 100644
--- a/pkgs/applications/audio/squeezelite/default.nix
+++ b/pkgs/applications/audio/squeezelite/default.nix
@@ -78,6 +78,8 @@ stdenv.mkDerivation {
     runHook postInstall
   '';
 
+  passthru.updateScript = ./update.sh;
+
   meta = with lib; {
     description = "Lightweight headless squeezebox client emulator";
     homepage = "https://github.com/ralph-irving/squeezelite";
diff --git a/pkgs/applications/audio/squeezelite/update.sh b/pkgs/applications/audio/squeezelite/update.sh
new file mode 100755
index 00000000000..d12213f8348
--- /dev/null
+++ b/pkgs/applications/audio/squeezelite/update.sh
@@ -0,0 +1,19 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i bash -p common-updater-scripts coreutils curl gnused jq nix nix-prefetch-github ripgrep
+
+set -euo pipefail
+
+latestRev="$(curl -s "https://api.github.com/repos/ralph-irving/squeezelite/commits?per_page=1" | jq -r ".[0].sha")"
+latestVersion="$( curl -s https://raw.githubusercontent.com/ralph-irving/squeezelite/${latestRev}/squeezelite.h | rg 'define (MAJOR|MINOR|MICRO)_VERSION' | sed 's/#.*VERSION //' | tr '\n' '.' | sed  -e 's/"//g' -e 's/\.$//')"
+currentVersion=$(nix-instantiate --eval -E "with import ./. {}; squeezelite.version or (lib.getVersion squeezelite)" | tr -d '"')
+
+if [[ "$currentVersion" == "$latestVersion" ]]; then
+  echo "squeezelite is up-to-date: $currentVersion"
+  exit 0
+fi
+
+srcHash=$(nix-prefetch-github ralph-irving squeezelite --rev "$latestRev" | jq -r .sha256)
+srcHash=$(nix hash to-sri --type sha256 "$srcHash")
+
+
+update-source-version squeezelite "$latestVersion" "$srcHash" --rev="${latestRev}"