about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBruno BELANYI <bruno@belanyi.fr>2023-05-13 22:25:26 +0100
committerPeter Hoeg <peter@hoeg.com>2023-05-15 18:12:57 +0800
commitda95e6a2e6f1f4d104715bb3a231a9e4a65c1f1c (patch)
tree4bc3067cb2175a4fabc329b6a756c3b9710fc018
parent6250f8607c0f8550571fb6fe79c5da76cbeb91f7 (diff)
downloadnixlib-da95e6a2e6f1f4d104715bb3a231a9e4a65c1f1c.tar
nixlib-da95e6a2e6f1f4d104715bb3a231a9e4a65c1f1c.tar.gz
nixlib-da95e6a2e6f1f4d104715bb3a231a9e4a65c1f1c.tar.bz2
nixlib-da95e6a2e6f1f4d104715bb3a231a9e4a65c1f1c.tar.lz
nixlib-da95e6a2e6f1f4d104715bb3a231a9e4a65c1f1c.tar.xz
nixlib-da95e6a2e6f1f4d104715bb3a231a9e4a65c1f1c.tar.zst
nixlib-da95e6a2e6f1f4d104715bb3a231a9e4a65c1f1c.zip
psst: add update script
-rw-r--r--pkgs/applications/audio/psst/default.nix4
-rwxr-xr-xpkgs/applications/audio/psst/update.sh44
2 files changed, 48 insertions, 0 deletions
diff --git a/pkgs/applications/audio/psst/default.nix b/pkgs/applications/audio/psst/default.nix
index c96ee165becf..235ca89ed216 100644
--- a/pkgs/applications/audio/psst/default.nix
+++ b/pkgs/applications/audio/psst/default.nix
@@ -59,6 +59,10 @@ rustPlatform.buildRustPackage rec {
     install -Dm444 -t $out/share/applications ${desktopItem}/share/applications/*
   '';
 
+  passthru = {
+    updateScript = ./update.sh;
+  };
+
   meta = with lib; {
     description = "Fast and multi-platform Spotify client with native GUI";
     homepage = "https://github.com/jpochyla/psst";
diff --git a/pkgs/applications/audio/psst/update.sh b/pkgs/applications/audio/psst/update.sh
new file mode 100755
index 000000000000..9671ccab0262
--- /dev/null
+++ b/pkgs/applications/audio/psst/update.sh
@@ -0,0 +1,44 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i bash -p nix wget nix-prefetch-github jq coreutils
+
+# shellcheck shell=bash
+
+if [ -n "$GITHUB_TOKEN" ]; then
+    TOKEN_ARGS=(--header "Authorization: token $GITHUB_TOKEN")
+fi
+
+if [[ $# -gt 1 || $1 == -* ]]; then
+    echo "Regenerates packaging data for psst."
+    echo "Usage: $0 [git commit]"
+    exit 1
+fi
+
+set -x
+
+cd "$(dirname "$0")"
+rev="$1"
+
+set -euo pipefail
+
+if [ -z "$rev" ]; then
+    rev="$(wget -O- "${TOKEN_ARGS[@]}" "https://api.github.com/repos/jpochyla/psst/commits?per_page=1" | jq -r '.[0].sha')"
+fi
+
+version="unstable-$(date +%F)"
+
+# Sources
+src_hash=$(nix-prefetch-github jpochyla psst --rev "$rev" | jq -r .sha256)
+
+# Cargo.lock
+src="https://raw.githubusercontent.com/jpochyla/psst/$rev"
+wget "${TOKEN_ARGS[@]}" "$src/Cargo.lock" -O Cargo.lock
+
+# Use friendlier hashes
+src_hash=$(nix hash to-sri --type sha256 "$src_hash")
+
+sed -i -E -e "s#version = \".*\"#version = \"$version\"#" default.nix
+sed -i -E -e "s#rev = \".*\"#rev = \"$rev\"#" default.nix
+sed -i -E -e "s#hash = \".*\"#hash = \"$src_hash\"#" default.nix
+
+# Also update the git hash shown in the UI
+sed -i -E -e "s#GIT_VERSION = \".*\"#GIT_VERSION = \"$rev\"#" make-build-reproducible.patch