diff --git a/pkgs/by-name/ma/mactracker/package.nix b/pkgs/by-name/ma/mactracker/package.nix index faf8d004e70a6..430373fe90c58 100644 --- a/pkgs/by-name/ma/mactracker/package.nix +++ b/pkgs/by-name/ma/mactracker/package.nix @@ -3,15 +3,24 @@ stdenvNoCC, fetchurl, unzip, + writeShellApplication, + curl, + cacert, + libxml2, + xmlstarlet, + common-updater-scripts, + versionCheckHook, + writeShellScript, + xcbuild, }: stdenvNoCC.mkDerivation (finalAttrs: { pname = "mactracker"; - version = "7.13"; + version = "7.13.2"; src = fetchurl { url = "https://mactracker.ca/downloads/Mactracker_${finalAttrs.version}.zip"; - hash = "sha256-GbaGhYF9Pf3EpzoLQd9fkWYxHFwCkYdlRyy33lieUxM="; + hash = "sha256-Ns2es6uMqfHKmeVV6ehGXV0pNtv2T3eNYLnRvsjOhpE="; }; dontPatch = true; @@ -31,6 +40,29 @@ stdenvNoCC.mkDerivation (finalAttrs: { runHook postInstall ''; + passthru.updateScript = lib.getExe (writeShellApplication { + name = "mactracker-update-script"; + runtimeInputs = [ + curl + cacert + libxml2 + xmlstarlet + common-updater-scripts + ]; + text = '' + url="https://mactracker.ca/releasenotes-mac.html" + version=$(curl -s "$url" | xmllint -html -xmlout - | xmlstarlet sel -t -v "//faq/h5[1]") + update-source-version mactracker "$version" + ''; + }); + + nativeInstallCheckInputs = [ versionCheckHook ]; + versionCheckProgram = writeShellScript "version-check" '' + ${xcbuild}/bin/PlistBuddy -c "Print :CFBundleVersion" "$1" + ''; + versionCheckProgramArg = [ "${placeholder "out"}/Applications/Mactracker.app/Contents/Info.plist" ]; + doInstallCheck = true; + meta = { description = "Mactracker provides detailed information on every Apple Macintosh, iPod, iPhone, iPad, and Apple Watch ever made"; homepage = "https://mactracker.ca";