From 5d5a33a8e3c8ca92cbf4b1dfb6a8930fe87803c5 Mon Sep 17 00:00:00 2001 From: Matteo Pacini Date: Mon, 12 Aug 2024 08:41:27 +0100 Subject: [PATCH] loopwm: added updateScript --- pkgs/by-name/lo/loopwm/package.nix | 4 ++++ pkgs/by-name/lo/loopwm/update.sh | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100755 pkgs/by-name/lo/loopwm/update.sh diff --git a/pkgs/by-name/lo/loopwm/package.nix b/pkgs/by-name/lo/loopwm/package.nix index 5b1829a8ee04..bb3f2cca9a05 100644 --- a/pkgs/by-name/lo/loopwm/package.nix +++ b/pkgs/by-name/lo/loopwm/package.nix @@ -29,6 +29,10 @@ stdenvNoCC.mkDerivation (finalAttrs: { runHook postInstall ''; + passthru = { + updateScript = ./update.sh; + }; + meta = { description = "macOS Window management made elegant"; homepage = "https://github.com/MrKai77/Loop"; diff --git a/pkgs/by-name/lo/loopwm/update.sh b/pkgs/by-name/lo/loopwm/update.sh new file mode 100755 index 000000000000..82b720fa98fd --- /dev/null +++ b/pkgs/by-name/lo/loopwm/update.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p curl jq gnused + +set -euo pipefail + +cd "$(dirname "$0")" || exit 1 + +# Grab latest release version +LOOPWM_LATEST_VER="$(curl --fail -s ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} "https://api.github.com/repos/MrKai77/Loop/releases/latest" | jq -r '.tag_name' | sed 's/^v//')" +LOOPWM_CURRENT_VER="$(grep -oP 'version = "\K[^"]+' package.nix)" + +if [[ "$LOOPWM_LATEST_VER" == "$LOOPWM_CURRENT_VER" ]]; then + echo "loopwm is up-to-date" + exit 0 +fi + +LOOPWM_DARWIN_HASH="$(nix-hash --to-sri --type sha256 "$(nix-prefetch-url --type sha256 "https://github.com/MrKai77/Loop/releases/download/${LOOPWM_LATEST_VER}/Loop.zip")")" + +sed -i "s#hash = \".*\"#hash = \"$LOOPWM_DARWIN_HASH\"#g" package.nix +sed -i "s#version = \".*\";#version = \"$LOOPWM_LATEST_VER\";#g" package.nix