Unverified Commit 8dadcf61 authored by Sandro Jäckel's avatar Sandro Jäckel Committed by GitHub
Browse files

joplin-desktop: 3.4.12 -> 3.5.12, unpin electron (#480462)

parents 4ad4dcf7 fda07bac
Loading
Loading
Loading
Loading
+9 −15
Original line number Diff line number Diff line
@@ -2,36 +2,30 @@
  lib,
  stdenv,
  fetchzip,
  npm-lockfile-fix,
  buildNpmPackage,
  clang_20,

  name,
  url,
  hash,
  npmDepsHash,
  patches ? [ ],
}:

let
  releaseData = (lib.importJSON ./release-data.json).plugins."io.github.jackgruber.backup";
in

buildNpmPackage {
  inherit name npmDepsHash patches;
  name = "joplin-plugin-backup";

  inherit (releaseData) npmDepsHash;
  inherit patches;

  src = fetchzip {
    inherit url hash;
    postFetch = ''
      # Add missing integrity and resolved fields
      ${lib.getExe npm-lockfile-fix} $out/package-lock.json
    '';
    inherit (releaseData) url hash;
  };

  nativeBuildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
    clang_20 # clang_21 breaks keytar
  ];

  postPatch = ''
    sed -i '/preinstall/d' package.json
  '';

  npmBuildScript = "dist";

  installPhase = ''
+97 −74

File changed.

Preview size limit exceeded, changes collapsed.

+20 −34
Original line number Diff line number Diff line
@@ -13,37 +13,19 @@
  cairo,
  pixman,
  libsecret,
  electron_37,
  electron,
  xcbuild,
  buildPackages,
  callPackage,
  runCommand,
  libGL,
  clang_20,
  jq,
}:

let
  electron = electron_37;
  yarn-berry = yarn-berry_4;

  releaseData = lib.importJSON ./release-data.json;

  buildPlugin = import ./buildPlugin.nix;

  getPluginPatch =
    src: id:
    runCommand "${id}.diff" { } ''
      patch="${src}/packages/default-plugins/plugin-patches/${id}.diff"

      if [ -f "$patch" ]; then
        cp "$patch" "$out"
      else
        # create an empty patch file if it doesn't exist – can't check this from Nix code without IFD
        touch "$out"
      fi
    '';

  getDefaultPlugins = map (callPackage buildPlugin);
in

stdenv.mkDerivation (finalAttrs: {
@@ -70,16 +52,14 @@ stdenv.mkDerivation (finalAttrs: {
    hash = releaseData.deps_hash;
  };

  # allows overriding to disable building the plugins
  defaultPlugins = getDefaultPlugins (
    lib.mapAttrsToList (
      id: plugin:
      plugin
      // {
        patches = [ (getPluginPatch finalAttrs.src id) ];
      }
    ) releaseData.plugins
  );
  # allows overriding to disable building these plugins or add other ones
  defaultPlugins = [
    (callPackage ./joplin-plugin-backup.nix {
      patches = [
        (finalAttrs.src + "/packages/default-plugins/plugin-patches/io.github.jackgruber.backup.diff")
      ];
    })
  ];

  buildInputs = [
    libGL
@@ -96,6 +76,7 @@ stdenv.mkDerivation (finalAttrs: {
    pixman
    libsecret
    makeWrapper
    jq
  ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [
    xcbuild
@@ -120,21 +101,26 @@ stdenv.mkDerivation (finalAttrs: {
    sed -i '/postinstall/d' package.json
    # Don't install onenote-converter subpackage deps
    sed -i '/onenote-converter/d' packages/{lib,app-desktop}/package.json
    # Don't build the default plugins, would require networking. We build them separately.
    sed -i "/'buildDefaultPlugins',/d" packages/app-desktop/gulpfile.ts
  '';

  buildPhase = ''
    runHook preBuild

    unset YARN_ENABLE_SCRIPTS

    for node_modules in packages/*/node_modules; do
      patchShebangs $node_modules
    done

    unset YARN_ENABLE_SCRIPTS

    yarn config set enableInlineBuilds true

    # fails otherwise because it tries to set up git hooks, not needed here
    sed -i 's/"preinstall": ".*"/"preinstall": "echo skipped preinstall"/' packages/default-plugins/node_modules/joplin-plugin-freehand-drawing/package.json

    # Don't let joplin build plugins from source, would require networking. We build them separately.
    pluginRepositories=packages/default-plugins/pluginRepositories.json
    jq 'with_entries(select(.value | has("package")))' <<< "$(cat $pluginRepositories)" > $pluginRepositories

    echo "installing yarn dependencies..."
    yarn workspaces focus \
      root \
+6 −12
Original line number Diff line number Diff line
{
  "version": "3.4.12",
  "hash": "sha256-p9MY7E0qa7LcXBpGs/DmX2A2jXQoOPYiRo/nEzkkQd0=",
  "version": "3.5.12",
  "hash": "sha256-NUWb2y8sTIzKTURJymb0Bvidz1tl+u3Q7o1UvEnIUtI=",
  "plugins": {
    "io.github.jackgruber.backup": {
      "name": "joplin-plugin-backup",
      "url": "https://github.com/JackGruber/joplin-plugin-backup/archive/abb58175e2d2bf34899f1b32cb74137e5c788bf9.tar.gz",
      "hash": "sha256-3J7TP3UClLDH402UqppQMsc1WmFjYIpIQ4uwGlTsyBs=",
      "npmDepsHash": "sha256-Grn4KQck6o+k8fj6qPxmx7S+4PTWvY5N4pE7Bj+47ps="
    },
    "io.github.personalizedrefrigerator.js-draw": {
      "name": "joplin-plugin-freehand-drawing",
      "url": "https://github.com/personalizedrefrigerator/joplin-plugin-freehand-drawing/archive/63b6d3f185b5b3664632e498df7c7ad7824038d0.tar.gz",
      "hash": "sha256-4sl+ktdMQ8PSELAeWMv9Ezgwrx5YDcC/7ou2ZSF2OyQ=",
      "npmDepsHash": "sha256-qwhVFSDafTnKihcwZtLK5fS/Nc15e+ezAso47T1LGec="
      "url": "https://github.com/JackGruber/joplin-plugin-backup/archive/2c3da7056e7ac39c86c2051a4fdb99d9534dd0a1.tar.gz",
      "hash": "sha256-rPmBg/+mJH7Fp26gVzuSGFxi1Y4MtfRT+hqppk3tHdY=",
      "npmDepsHash": "sha256-xZJ0Oir1A6sLe0ztIyBu39Yy3D6sNrVaciOYG0k85l0="
    }
  },
  "deps_hash": "sha256-7sZX39OtNNPq5RE7+Oj58QqHhcrTY8FOdncKp3b40jQ="
  "deps_hash": "sha256-9xJmudcpUw1xmTvJD3TFrfzYEi+LupZGSzsA5zUOemI="
}
+18 −33
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 nix-prefetch-git yarn-berry_4 yarn-berry_4.yarn-berry-fetcher prefetch-npm-deps
#!nix-shell -i python3 -p 'python3.withPackages(ps: [ps.requests ps.plumbum])' nurl nix-prefetch-git yarn-berry_4 yarn-berry_4.yarn-berry-fetcher prefetch-npm-deps
import json
import requests
import tempfile
@@ -7,9 +7,10 @@ import shutil

from pathlib import Path

from plumbum.cmd import nix_prefetch, nix_build, yarn, chmod, yarn_berry_fetcher, prefetch_npm_deps, diff
from plumbum.cmd import nurl, nix_build, yarn, chmod, yarn_berry_fetcher, prefetch_npm_deps, diff, git, nix

HERE = Path(__file__).parent
NIXPKGS_ROOT = git.with_cwd(HERE)["rev-parse", "--show-toplevel"]().strip()

def write_release(release):
    with HERE.joinpath("release-data.json").open("w") as fd:
@@ -43,16 +44,9 @@ print(version)

print("prefetching source...")

release["hash"] = nix_prefetch[
    "--option",
    "extra-experimental-features",
    "flakes",
    "--tag",
    f"v{version}",
    "--rev",
    "--expr",
    "null",
    package
release["hash"] = nurl[
    "-e",
    f'(import {NIXPKGS_ROOT}/. {{}}).joplin-desktop.src.overrideAttrs(_:{{tag="{tag}";}})'
]().strip()

print(release["hash"])
@@ -63,7 +57,7 @@ write_release(release)
src_dir = nix_build[
    "--no-out-link",
    "-E",
    f"((import <nixpkgs> {{}}).callPackage {package} {{}}).src"
    f"(import {NIXPKGS_ROOT}/. {{}}).joplin-desktop.src"
]().strip()

print(src_dir)
@@ -79,32 +73,23 @@ with default_plugins_dir.joinpath("pluginRepositories.json").open() as fd:
release["plugins"] = dict()

for key, value in plugin_repositories.items():
    if "package" in value:
        print("skipping npm-packaged plugin", key)
        continue

    print(key)

    plugin = {
        "name": "",
        "url": "",
        "hash": "",
        "npmDepsHash": "",
        "name": value["cloneUrl"].split("/")[-1].removesuffix(".git"),
        "url": f"{value["cloneUrl"].removesuffix('.git')}/archive/{value["commit"]}.tar.gz",
    }

    plugin["name"] = value["cloneUrl"].split("/")[-1].removesuffix(".git")

    plugin["url"] = f"{value["cloneUrl"].removesuffix('.git')}/archive/{value["commit"]}.tar.gz"

    plugin["hash"] = nix_prefetch.with_cwd(HERE)[
        "--option",
        "extra-experimental-features",
        "flakes",
        f"((import <nixpkgs> {{}}).callPackage ./buildPlugin.nix {dict_to_argstr(plugin)}).src"
    ]().strip()
    fetched_src = json.loads(
        nix["store", "prefetch-file", "--json", "--unpack", plugin["url"]]()
    )
    plugin["hash"] = fetched_src["hash"]

    plugin_src = nix_build.with_cwd(HERE)[
        "--no-out-link",
        "-E",
        f"((import <nixpkgs> {{}}).callPackage ./buildPlugin.nix {dict_to_argstr(plugin)}).src"
    ]().strip()
    plugin["npmDepsHash"] = prefetch_npm_deps(Path(plugin_src).joinpath("package-lock.json")).strip()
    plugin["npmDepsHash"] = prefetch_npm_deps(Path(fetched_src["storePath"]).joinpath("package-lock.json")).strip()

    release["plugins"][key] = plugin