karabiner-elements: Add updateScript

This commit is contained in:
Varun Madiath 2023-03-28 07:12:56 -04:00
parent ac01c345ad
commit dbf278b976
2 changed files with 15 additions and 0 deletions

View file

@ -40,6 +40,8 @@ stdenv.mkDerivation rec {
cp "$out/Library/Application Support/org.pqrs/Karabiner-Elements/package-version" "$out/Library/Application Support/org.pqrs/Karabiner-Elements/version"
'';
passthru.updateScript = ./updater.sh;
meta = with lib; {
description = "Karabiner-Elements is a powerful utility for keyboard customization on macOS Sierra (10.12) or later.";
homepage = "https://karabiner-elements.pqrs.org/";

View file

@ -0,0 +1,13 @@
#!/usr/bin/env nix-shell
#!nix-shell -I nixpkgs=./. -i bash -p curl jq common-updater-scripts
set -eo pipefail
new_version="$(curl -s "https://api.github.com/repos/pqrs-org/Karabiner-Elements/releases/latest" | jq -r '.tag_name | ltrimstr("v")')"
old_version="$(sed -nE 's/\s*version = "(.*)".*/\1/p' ./default.nix)"
if [[ "$new_version" == "$old_version" ]]; then
echo "Already up to date!"
exit 0
fi
update-source-version karabiner-elements "${new_version}"