Unverified Commit c1416403 authored by Aleksana's avatar Aleksana Committed by GitHub
Browse files

gitkraken: setup auto-update script (#400203)

parents 163b5859 95c40b02
Loading
Loading
Loading
Loading
+45 −42
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  libXcomposite,
  libgnome-keyring,
  buildPackages,
  copyDesktopItems,
  fetchzip,
  makeDesktopItem,
  makeWrapper,
  udev,
  curlWithGnuTls,
  adwaita-icon-theme,
  alsa-lib,
  libXfixes,
  at-spi2-atk,
  at-spi2-core,
  atk,
  gtk3,
  libXrender,
  pango,
  adwaita-icon-theme,
  cacert,
  cairo,
  freetype,
  fontconfig,
  libX11,
  libXi,
  libxcb,
  libXext,
  libXcursor,
  glib,
  libXScrnSaver,
  libxkbfile,
  libXtst,
  nss,
  nspr,
  cups,
  fetchzip,
  curlWithGnuTls,
  dbus,
  e2fsprogs,
  expat,
  fontconfig,
  freetype,
  gdk-pixbuf,
  git,
  glib,
  gtk3,
  krb5,
  libGL,
  libX11,
  libXScrnSaver,
  libXcomposite,
  libXcursor,
  libXdamage,
  libXext,
  libXfixes,
  libXi,
  libXrandr,
  dbus,
  makeDesktopItem,
  openssl,
  wrapGAppsHook3,
  buildPackages,
  at-spi2-atk,
  at-spi2-core,
  libuuid,
  e2fsprogs,
  krb5,
  libXrender,
  libXtst,
  libdrm,
  libgbm,
  unzip,
  copyDesktopItems,
  libxshmfence,
  libgnome-keyring,
  libuuid,
  libxcb,
  libxkbcommon,
  git,
  libGL,
  libxkbfile,
  libxshmfence,
  nspr,
  nss,
  openssl,
  pango,
  udev,
  unzip,
  zlib,
  cacert,
}:

let
@@ -80,25 +79,28 @@ let

  src = srcs.${stdenv.hostPlatform.system} or throwSystem;

  meta = with lib; {
  meta = {
    homepage = "https://www.gitkraken.com/git-client";
    description = "Simplifying Git for any OS";
    sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
    license = licenses.unfree;
    license = lib.licenses.unfree;
    platforms = builtins.attrNames srcs;
    maintainers = with maintainers; [
    maintainers = with lib.maintainers; [
      nicolas-goudry
      Rishik-Y
    ];
    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 = [
+31 −0
Original line number Diff line number Diff line
#!/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 <architecture> -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!"