unityhub: add update script

This commit is contained in:
huantian 2023-04-19 16:56:52 -07:00
parent 6eceb07c28
commit 64a3cb7347
No known key found for this signature in database
GPG key ID: 4A0318E04E555DE5
2 changed files with 15 additions and 0 deletions

View file

@ -119,6 +119,8 @@ stdenv.mkDerivation rec {
runHook postInstall
'';
passthru.updateScript = ./update.sh;
meta = with lib; {
description = "Official Unity3D app to download and manage Unity Projects and installations";
homepage = "https://unity3d.com/";

View file

@ -0,0 +1,13 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl common-updater-scripts
# set -euo pipefail
new_version="$(curl https://hub-dist.unity3d.com/artifactory/hub-debian-prod-local/dists/stable/main/binary-amd64/Packages --silent | sed -nE "s/^Version: ([0-9]+\.[0-9]+\.[0-9]+)$/\1/p" | sort -V | tail -n 1)"
old_version="$(sed -nE 's/^\s*version = "([0-9]+\.[0-9]+\.[0-9]+)";$/\1/p' ./default.nix)"
if [[ "$new_version" == "$old_version" ]]; then
echo "Up to date"
exit 0
fi
update-source-version unityhub "$new_version"