From 95c40b02fca88ec29b29e09258a5360bfc0f7695 Mon Sep 17 00:00:00 2001 From: Nicolas Goudry Date: Sat, 19 Apr 2025 14:52:17 +0200 Subject: [PATCH] gitkraken: setup auto-update script --- pkgs/by-name/gi/gitkraken/package.nix | 5 ++++- pkgs/by-name/gi/gitkraken/update.sh | 31 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100755 pkgs/by-name/gi/gitkraken/update.sh diff --git a/pkgs/by-name/gi/gitkraken/package.nix b/pkgs/by-name/gi/gitkraken/package.nix index 6478f127006b..0d837e9899bd 100644 --- a/pkgs/by-name/gi/gitkraken/package.nix +++ b/pkgs/by-name/gi/gitkraken/package.nix @@ -6,7 +6,6 @@ fetchzip, makeDesktopItem, makeWrapper, - nix-update-script, adwaita-icon-theme, alsa-lib, at-spi2-atk, @@ -93,12 +92,15 @@ let mainProgram = "gitkraken"; }; + passthru.updateScript = ./update.sh; + linux = stdenv.mkDerivation rec { inherit pname version src meta + passthru ; dontBuild = true; @@ -228,6 +230,7 @@ let version src meta + passthru ; nativeBuildInputs = [ diff --git a/pkgs/by-name/gi/gitkraken/update.sh b/pkgs/by-name/gi/gitkraken/update.sh new file mode 100755 index 000000000000..dfc7dd773ac2 --- /dev/null +++ b/pkgs/by-name/gi/gitkraken/update.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p common-updater-scripts curl jq + +set -euo pipefail + +scriptDir=$(cd "${BASH_SOURCE[0]%/*}" && pwd) +nixpkgs=$(realpath "$scriptDir"/../../../..) + +# All architectures are released together, therefore we get the latest version from the linux release +# NOTE: for some reason, the darwin RELEASES (ie. /darwin/RELEASES) file returns a frozen version... +echo >&2 "=== Obtaining version data from release.axocdn.com..." +version=$(curl -fsSL https://release.axocdn.com/linux/RELEASES | jq -r '.name') + +# Hardcoded URLs to compute hashes +declare -A tarballs=( + ["x86_64-linux"]="https://release.axocdn.com/linux/GitKraken-v${version}.tar.gz" + ["x86_64-darwin"]="https://release.axocdn.com/darwin/GitKraken-v${version}.zip" + ["aarch64-darwin"]="https://release.axocdn.com/darwin-arm64/GitKraken-v${version}.zip" +) + +for arch in "${!tarballs[@]}"; do + # We precalculate the hash before calling update-source-version because it attempts to calculate each architecture's + # package's hash by running `nix-build --system -A gitkraken.src` which causes cross compiling headaches + echo >&2 "=== Downloading ${arch} package and computing its hash..." + hash=$(nix-hash --sri --type sha256 "$(nix-prefetch-url --print-path --unpack "${tarballs[${arch}]}" | tail -n1)") + echo >&2 "=== Updating package.nix for ${arch}..." + # update-source-version expects to be at the root of nixpkgs + (cd "${nixpkgs}" && update-source-version gitkraken "${version}" "${hash}" --system="${arch}" --version-key="srcs.${arch}") +done + +echo >&2 "=== Done!"