Commit 942a3ba0 authored by Jairo Llopis's avatar Jairo Llopis Committed by Jairo Llopis
Browse files

joplin-desktop: add multiarch update script

parent 0983e363
Loading
Loading
Loading
Loading
+7 −19
Original line number Diff line number Diff line
@@ -9,29 +9,13 @@

let
  pname = "joplin-desktop";
  version = "3.1.24";
  inherit (releaseData) version;

  inherit (stdenv.hostPlatform) system;
  throwSystem = throw "Unsupported system: ${system}";

  suffix =
    {
      x86_64-linux = ".AppImage";
      x86_64-darwin = ".dmg";
      aarch64-darwin = "-arm64.dmg";
    }
    .${system} or throwSystem;

  src = fetchurl {
    url = "https://github.com/laurent22/joplin/releases/download/v${version}/Joplin-${version}${suffix}";
    sha256 =
      {
        x86_64-linux = "sha256-ImFB4KwJ/vAHtZUbLAdnIRpd+o2ZaXKy9luw/jnPLSE=";
        x86_64-darwin = "sha256-Of6VXX40tCis+ou26LtJKOZm/87P3rsTHtnvSDwF8VY=";
        aarch64-darwin = "sha256-HtHuZQhIkiI8GrhB9nCOTAN1hOs+9POJFRIsRUNikYs=";
      }
      .${system} or throwSystem;
  };
  releaseData = lib.importJSON ./release-data.json;
  src = fetchurl releaseData.${system} or throwSystem;

  appimageContents = appimageTools.extractType2 {
    inherit pname version src;
@@ -82,6 +66,8 @@ let
      substituteInPlace $out/share/applications/joplin.desktop \
        --replace-fail 'Exec=AppRun' 'Exec=joplin-desktop'
    '';

    passthru.updateScript = ./update.py;
  };

  darwin = stdenv.mkDerivation {
@@ -108,6 +94,8 @@ let
      cp -R Joplin.app $out/Applications
      runHook postInstall
    '';

    passthru.updateScript = ./update.py;
  };
in
if stdenv.hostPlatform.isDarwin then darwin else linux
+15 −0
Original line number Diff line number Diff line
{
  "version": "3.1.24",
  "x86_64-linux": {
    "url": "https://github.com/laurent22/joplin/releases/download/v3.1.24/Joplin-3.1.24.AppImage",
    "sha256": "089drwwzxc2vysr74scripx5s6i1cw3jq6wmnl3z1zh9mkh42q92"
  },
  "x86_64-darwin": {
    "url": "https://github.com/laurent22/joplin/releases/download/v3.1.24/Joplin-3.1.24.dmg",
    "sha256": "0mpi0ly4ivyr3q9vppngrvzndri896xyidlbzan2id1lgrfrbzir"
  },
  "aarch64-darwin": {
    "url": "https://github.com/laurent22/joplin/releases/download/v3.1.24/Joplin-3.1.24-arm64.dmg",
    "sha256": "12wic91lab0j2n4z7x1yxf27a0scirqgchdq38y254j811jyxl8y"
  }
}
 No newline at end of file
+32 −0
Original line number Diff line number Diff line
#!/usr/bin/env nix-shell
#!nix-shell -i python3 -p 'python3.withPackages(ps: [ps.requests ps.plumbum])' nix-prefetch
import json
import requests

from pathlib import Path

from plumbum.cmd import nix_prefetch_url

HERE = Path(__file__).parent
SUFFIXES = (
    ("x86_64-linux", ".AppImage"),
    ("x86_64-darwin", ".dmg"),
    ("aarch64-darwin", "-arm64.dmg"),
)

latest = requests.get(
    "https://api.github.com/repos/laurent22/joplin/releases/latest"
).json()
tag = latest["tag_name"]
version = tag[1:]
release = {
    "version": version,
}

for arch, suffix in SUFFIXES:
    url = f"https://github.com/laurent22/joplin/releases/download/v{version}/Joplin-{version}{suffix}"
    release[arch] = {"url": url, "sha256": nix_prefetch_url(url).strip()}

with HERE.joinpath("release-data.json").open("w") as fd:
    json.dump(release, fd, indent=2)
    fd.write("\n")