Unverified Commit e48a0648 authored by Kira Bruneau's avatar Kira Bruneau Committed by GitHub
Browse files

anytype: add custom update script (#441095)

parents 5b1e62b8 1de05583
Loading
Loading
Loading
Loading
+16 −15
Original line number Diff line number Diff line
@@ -10,17 +10,6 @@
}:

let
  pname = "anytype-heart";
  # Use only versions specified in anytype-ts middleware.version file:
  #  https://github.com/anyproto/anytype-ts/blob/v<anytype-ts-version>/middleware.version
  version = "0.43.0-rc02";
  src = fetchFromGitHub {
    owner = "anyproto";
    repo = "anytype-heart";
    tag = "v${version}";
    hash = "sha256-hqDwzW1Tl44ipL1EAwlXUoKaQ0Wvfa2rtZMQy4pgQ8k=";
  };

  arch =
    {
      # https://github.com/anyproto/anytype-heart/blob/f33a6b09e9e4e597f8ddf845fc4d6fe2ef335622/pkg/lib/localstore/ftsearch/ftsearchtantivy.go#L3
@@ -31,10 +20,20 @@ let
    }
    .${stdenv.hostPlatform.system}
      or (throw "anytype-heart not supported on ${stdenv.hostPlatform.system}");

in
buildGoModule {
  inherit pname version src;
buildGoModule (finalAttrs: {
  pname = "anytype-heart";

  # Use only versions specified in anytype-ts middleware.version file:
  #  https://github.com/anyproto/anytype-ts/blob/v<anytype-ts-version>/middleware.version
  version = "0.43.0-rc02";

  src = fetchFromGitHub {
    owner = "anyproto";
    repo = "anytype-heart";
    tag = "v${finalAttrs.version}";
    hash = "sha256-hqDwzW1Tl44ipL1EAwlXUoKaQ0Wvfa2rtZMQy4pgQ8k=";
  };

  vendorHash = "sha256-Rs+CusvMksyXUplGk09J4CiFgl/D4KtsI9C15dSCjOI=";

@@ -83,10 +82,12 @@ buildGoModule {
  meta = {
    description = "Shared library for Anytype clients";
    homepage = "https://anytype.io/";
    changelog = "https://github.com/anyproto/anytype-heart/releases/tag/${finalAttrs.src.tag}";
    license = lib.licenses.unfreeRedistributable;
    maintainers = with lib.maintainers; [
      autrimpo
      adda
      kira-bruneau
    ];
    platforms = [
      "x86_64-linux"
@@ -95,4 +96,4 @@ buildGoModule {
      "aarch64-darwin"
    ];
  };
}
})
+12 −10
Original line number Diff line number Diff line
@@ -12,17 +12,16 @@
  commandLineArgs ? "",
}:

let
buildNpmPackage (finalAttrs: {
  pname = "anytype";
  version = "0.49.2";

  src = fetchFromGitHub {
    owner = "anyproto";
    repo = "anytype-ts";
    tag = "v${version}";
    tag = "v${finalAttrs.version}";
    hash = "sha256-8+x2FmyR5x9Zrm3t71RSyxAKcJCvnR98+fqHXjBE7aU=";
  };
  description = "P2P note-taking tool";

  locales = fetchFromGitHub {
    owner = "anyproto";
@@ -30,9 +29,6 @@ let
    rev = "873b42df7320ebbbc80d7e2477914dac70363ef7";
    hash = "sha256-Mr0KfXn9NO86QqgBhVjSs2przN/GtjuhJHJ9djo8Feg=";
  };
in
buildNpmPackage {
  inherit pname version src;

  npmDepsHash = "sha256-fuNTSZl+4DG/YL34f/+bYK26ruRFAc1hyHVAm256LiE=";

@@ -62,7 +58,7 @@ buildNpmPackage {
    cp -r ${anytype-heart}/lib dist/
    cp -r ${anytype-heart}/bin/anytypeHelper dist/

    for lang in ${locales}/locales/*; do
    for lang in ${finalAttrs.locales}/locales/*; do
      cp "$lang" "dist/lib/json/lang/$(basename $lang)"
    done

@@ -106,7 +102,7 @@ buildNpmPackage {
      exec = "anytype %U";
      icon = "anytype";
      desktopName = "Anytype";
      comment = description;
      comment = finalAttrs.meta.description;
      mimeTypes = [ "x-scheme-handler/anytype" ];
      categories = [
        "Utility"
@@ -118,14 +114,20 @@ buildNpmPackage {
    })
  ];

  passthru.updateScript = ./update.sh;

  meta = {
    inherit description;
    description = "P2P note-taking tool";
    homepage = "https://anytype.io/";
    changelog = "https://community.anytype.io/t/anytype-desktop-${
      builtins.replaceStrings [ "." ] [ "-" ] (lib.versions.majorMinor finalAttrs.version)
    }-0-released";
    license = lib.licenses.unfreeRedistributable;
    mainProgram = "anytype";
    maintainers = with lib.maintainers; [
      autrimpo
      adda
      kira-bruneau
    ];
    platforms = [
      "x86_64-linux"
@@ -135,4 +137,4 @@ buildNpmPackage {
    ];
    broken = stdenv.hostPlatform.isDarwin;
  };
}
})
+61 −0
Original line number Diff line number Diff line
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p common-updater-scripts coreutils curl jq nix-update

set -euo pipefail

anytype_version=null
release_page=1

# Anytype often has many pre-releases between releases, which can span multiple pages
while [ "$anytype_version" = 'null' ]; do
  readarray -t release < <(
    curl "https://api.github.com/repos/anyproto/anytype-ts/releases?page=$release_page" \
      ${GITHUB_TOKEN:+--user ":$GITHUB_TOKEN"} \
      --silent \
    | jq --raw-output '
      map(select(
        (.prerelease == false) and
        (.tag_name | test("alpha|beta") | not)
      )) | .[0] | .tag_name, .created_at
    '
  )
  anytype_version=${release[0]//v}
  anytype_release_date=${release[1]}
  release_page=$((release_page+1))
done

if [ "$UPDATE_NIX_OLD_VERSION" = "$anytype_version" ]; then
  echo "Already up to date!"
  exit 0
fi

# https://github.com/anyproto/anytype-ts/blob/v0.49.2/electron/hook/locale.js
locales_rev=$(
  curl "https://api.github.com/repos/anyproto/l10n-anytype-ts/commits?until=$anytype_release_date&per_page=1" \
    ${GITHUB_TOKEN:+--user ":$GITHUB_TOKEN"} \
    --silent \
  | jq --raw-output '.[0].sha'
)

# https://github.com/anyproto/anytype-ts/blob/v0.49.2/update.sh
middleware_version=$(
  curl "https://raw.githubusercontent.com/anyproto/anytype-ts/refs/tags/v$anytype_version/middleware.version" \
    ${GITHUB_TOKEN:+--user ":$GITHUB_TOKEN"} \
    --silent
)

# https://github.com/anyproto/anytype-heart/blob/v0.42.4/makefiles/vars.mk#L8
tantivy_go_version=$(
  curl "https://raw.githubusercontent.com/anyproto/anytype-heart/refs/tags/v$middleware_version/go.mod" \
    ${GITHUB_TOKEN:+--user ":$GITHUB_TOKEN"} \
    --silent \
  | grep github.com/anyproto/tantivy-go \
  | cut --delimiter=' ' --field=2
)

tantivy_go_version=${tantivy_go_version//v}

nix-update tantivy-go --version "$tantivy_go_version" --generate-lockfile
nix-update anytype-heart --version "$middleware_version"
update-source-version anytype --ignore-same-version --source-key=locales --rev="$locales_rev"
nix-update anytype --version "$anytype_version"
+1908 −0

File added.

Preview size limit exceeded, changes collapsed.

+0 −1914

File deleted.

Preview size limit exceeded, changes collapsed.

Loading