diff --git a/pkgs/by-name/an/anytype-heart/package.nix b/pkgs/by-name/an/anytype-heart/package.nix index 69e632df434c..5b11214a178c 100644 --- a/pkgs/by-name/an/anytype-heart/package.nix +++ b/pkgs/by-name/an/anytype-heart/package.nix @@ -26,7 +26,7 @@ buildGoModule (finalAttrs: { # Use only versions specified in anytype-ts middleware.version file: # https://github.com/anyproto/anytype-ts/blob/v/middleware.version - version = "0.49.0-rc08"; + version = "0.50.8"; # Update only together with 'anytype' package. # nixpkgs-update: no auto update @@ -34,10 +34,10 @@ buildGoModule (finalAttrs: { owner = "anyproto"; repo = "anytype-heart"; tag = "v${finalAttrs.version}"; - hash = "sha256-gTUesFf6cDwsFCEUjpcy9VA67GwuZ9mNTih4HC0Vi7g="; + hash = "sha256-h59Vnmv+iB0NbLQPCHPlmHBDaYoFimrZP/4Cv/IQ7b8="; }; - vendorHash = "sha256-1D7v/lgmoKOOHNG3vgpzDpWQ66lmmP8IeZ5rvXe4D9M="; + vendorHash = "sha256-uJ/Z2zxqIne3UuxAglZejoqHV/IchYdPhefL9K51U2I="; subPackages = [ "cmd/grpcserver" ]; tags = [ @@ -59,16 +59,11 @@ buildGoModule (finalAttrs: { cp ${tantivy-go}/lib/libtantivy_go.a deps/libs/${arch} ''; - postBuild = '' - protoc -I ./ --js_out=import_style=commonjs,binary:./dist/js/pb pb/protos/service/*.proto pb/protos/*.proto pkg/lib/pb/model/protos/*.proto - protoc -I ./ --grpc-web_out=import_style=commonjs+dts,mode=grpcwebtext:./dist/js/pb pb/protos/service/*.proto pb/protos/*.proto pkg/lib/pb/model/protos/*.proto - ''; - postInstall = '' mv $out/bin/grpcserver $out/bin/anytypeHelper - mkdir -p $out/lib - cp -r dist/js/pb/* $out/lib - cp -r dist/js/pb/* $out/lib + mkdir -p $out/lib/protos + find pb -type f -name "*.proto" -exec cp {} $out/lib/protos/ \; + find pkg/lib/pb -type f -name "*.proto" -exec cp {} $out/lib/protos/ \; mkdir -p $out/lib/json/generated cp pkg/lib/bundle/system*.json $out/lib/json/generated diff --git a/pkgs/by-name/an/anytype/0001-feat-update-Disable-auto-checking-for-updates-and-updating-manually.patch b/pkgs/by-name/an/anytype/0001-feat-update-Disable-auto-checking-for-updates-and-updating-manually.patch index 7931ec439968..c8e17042b595 100644 --- a/pkgs/by-name/an/anytype/0001-feat-update-Disable-auto-checking-for-updates-and-updating-manually.patch +++ b/pkgs/by-name/an/anytype/0001-feat-update-Disable-auto-checking-for-updates-and-updating-manually.patch @@ -1,18 +1,8 @@ -From d236396b1da80a7233168e01e8164256e7f69cc1 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?David=20Chocholat=C3=BD?= -Date: Fri, 25 Apr 2025 12:29:37 +0200 -Subject: [PATCH] feat(update): Disable auto checking for updates and updating - manually - ---- - electron/js/update.js | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/electron/js/update.js b/electron/js/update.js -index 0e34efa..9386c90 100644 ---- a/electron/js/update.js -+++ b/electron/js/update.js -@@ -29,7 +29,8 @@ class UpdateManager { +diff --git a/electron/ts/update.ts b/electron/ts/update.ts +index 8d63cb8eb7..ea2dadf0c9 100644 +--- a/electron/ts/update.ts ++++ b/electron/ts/update.ts +@@ -31,7 +31,8 @@ class UpdateManager { autoUpdater.autoInstallOnAppQuit = false; autoUpdater.channel = channel; @@ -22,16 +12,13 @@ index 0e34efa..9386c90 100644 autoUpdater.on('checking-for-update', () => { Util.log('info', 'Checking for update'); -@@ -93,6 +94,9 @@ class UpdateManager { +@@ -79,6 +80,9 @@ class UpdateManager { }; - isAllowed () { + isAllowed (): boolean { + // PATCH(update): Always disallow update check, even when requested by the user manually or when Anytype starts. + return false; + const { config } = ConfigManager; if (config.updateDisabled) { --- -2.49.0 - diff --git a/pkgs/by-name/an/anytype/0002-remove-grpc-devtools.patch b/pkgs/by-name/an/anytype/0002-remove-grpc-devtools.patch index b0dad3b73d7b..9e594683b70e 100644 --- a/pkgs/by-name/an/anytype/0002-remove-grpc-devtools.patch +++ b/pkgs/by-name/an/anytype/0002-remove-grpc-devtools.patch @@ -1,12 +1,12 @@ -diff --git a/electron.js b/electron.js -index c5d6760882..17afc05e26 100644 ---- a/electron.js -+++ b/electron.js -@@ -15,7 +15,6 @@ const store = new Store({ name: [ 'localStorage', suffix ].join('-') }); - - // gRPC DevTools extension ID - const GRPC_DEVTOOLS_ID = 'fohdnlaeecihjiendkfhifhlgldpeopm'; --const { installExtension } = require('@tomjs/electron-devtools-installer'); - - // Fix notifications app name - if (is.windows) { +diff --git a/electron/ts/main.ts b/electron/ts/main.ts +index 373518ee2d..8eefcd58be 100644 +--- a/electron/ts/main.ts ++++ b/electron/ts/main.ts +@@ -15,7 +15,6 @@ import storage from 'electron-json-storage'; + import * as remote from '@electron/remote/main'; + import { installNativeMessagingHost } from './lib/installNativeMessagingHost'; + import { getSafeStorage } from './safeStorage'; +-import { installExtension } from '@tomjs/electron-devtools-installer'; + import Api from './api'; + import ConfigManager from './config'; + import UpdateManager from './update'; diff --git a/pkgs/by-name/an/anytype/0003-remove-desktop-entry.patch b/pkgs/by-name/an/anytype/0003-remove-desktop-entry.patch index e772bdff71c6..2b8eeb826c18 100644 --- a/pkgs/by-name/an/anytype/0003-remove-desktop-entry.patch +++ b/pkgs/by-name/an/anytype/0003-remove-desktop-entry.patch @@ -1,13 +1,12 @@ -diff --git a/electron/js/util.js b/electron/js/util.js -index da18f41ad0..bb07ec9f21 100644 ---- a/electron/js/util.js -+++ b/electron/js/util.js -@@ -314,7 +314,9 @@ class Util { - if (!is.linux) { +diff --git a/electron/ts/util.ts b/electron/ts/util.ts +index 1c5d6fd4b4..8c7811b58e 100644 +--- a/electron/ts/util.ts ++++ b/electron/ts/util.ts +@@ -318,6 +318,9 @@ class Util { return; }; -- -+ // NixOS: desktop entries are managed by the package, avoid + ++ // NixOS: desktop entries are managed by the package, avoid + // writing user-local anytype.desktop which goes stale on updates + return; const { execFile } = require('child_process'); diff --git a/pkgs/by-name/an/anytype/package.nix b/pkgs/by-name/an/anytype/package.nix index 12391fb12824..c51ad8832da4 100644 --- a/pkgs/by-name/an/anytype/package.nix +++ b/pkgs/by-name/an/anytype/package.nix @@ -1,57 +1,116 @@ { lib, stdenv, + stdenvNoCC, fetchFromGitHub, - buildNpmPackage, - nodejs_22, + makeWrapper, + coreutils, + nodejs, + node-gyp, + python3, + bun, pkg-config, anytype-heart, libsecret, electron, go, lsof, + protobuf, makeDesktopItem, copyDesktopItems, + writableTmpDirAsHomeHook, commandLineArgs ? "", }: -buildNpmPackage (finalAttrs: { +stdenvNoCC.mkDerivation (finalAttrs: { pname = "anytype"; - version = "0.54.11"; + version = "0.55.5"; + + strictDeps = true; src = fetchFromGitHub { owner = "anyproto"; repo = "anytype-ts"; tag = "v${finalAttrs.version}"; - hash = "sha256-HF7bP3Ry3djNQnFDl0v6x9hzMpSLMXyI6UBItgGT+DI="; + hash = "sha256-9myOd7LTH/NoRY4SjU7+FSSNIhDMGKRPTBOQOURk/Hs="; }; locales = fetchFromGitHub { owner = "anyproto"; repo = "l10n-anytype-ts"; - rev = "afa12aeb0cea6c77ce38c3e3bfd082d532948a1c"; - hash = "sha256-YpOkmm7vW97t19twfLNExRHQvLVcrC+oDtHjwJL9dx8="; + rev = "b96bf7b76f10e764e7a60c7f284854aaabedcec6"; + hash = "sha256-+vkProHi25CWxG74QB5eo0Pnwj0u5vXoZeeCoXyMOv4="; }; - npmDepsHash = "sha256-/QWHJ2grw34LOEIDn93WDTEpQH001vVtuQgncR2SRYQ="; + node_modules = stdenvNoCC.mkDerivation { + pname = "${finalAttrs.pname}-node_modules"; + inherit (finalAttrs) version src; - # npm dependency install fails with nodejs_24: https://github.com/NixOS/nixpkgs/issues/474535 - nodejs = nodejs_22; + impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [ + "GIT_PROXY_COMMAND" + "SOCKS_SERVER" + ]; + + nativeBuildInputs = [ + bun + writableTmpDirAsHomeHook + ]; + + dontConfigure = true; + + buildPhase = '' + runHook preBuild + + export BUN_INSTALL_CACHE_DIR=$(mktemp -d) + # https://bun.com/docs/pm/cli/install#configuring-with-environment-variables + + # Bun always tries to use the fastest available installation method for the target platform. On macOS, that’s clonefile and on Linux, that’s hardlink. + bun install \ + --backend=copyfile \ + --cpu="*" \ + --frozen-lockfile \ + --ignore-scripts \ + --no-progress \ + --os="*" + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + mkdir -p $out + find . -type d -name node_modules -exec cp -R --parents {} $out \; + + runHook postInstall + ''; + + dontFixup = true; + + #TODO: update it in update script + outputHash = "sha256-6IHFidjVDDzUOCRXVwjvzcLGKV6dWWS7k2jwrOuJ748="; + outputHashMode = "recursive"; + }; env = { ELECTRON_SKIP_BINARY_DOWNLOAD = "1"; }; nativeBuildInputs = [ + bun + nodejs pkg-config go + protobuf copyDesktopItems + makeWrapper + node-gyp + stdenv.cc + python3 ]; - buildInputs = [ libsecret ]; - npmFlags = [ - # keytar needs to be built against electron's ABI - "--nodedir=${electron.headers}" + buildInputs = [ + libsecret ]; patches = [ @@ -60,26 +119,54 @@ buildNpmPackage (finalAttrs: { ./0003-remove-desktop-entry.patch ]; + configurePhase = '' + runHook preConfigure + + cp -R ${finalAttrs.node_modules}/. . + patchShebangs node_modules + + runHook postConfigure + ''; + buildPhase = '' runHook preBuild + # Building keytar against electron's ABI + # Trying to build in temp dir, will not work due to the keytar calling the node -p require('node-addon-api').include_dir + # but building inside the node_modules/keytar will find the ../node-addon-api automatically + chmod -R u+w node_modules/keytar node_modules/node-addon-api + pushd node_modules/keytar + HOME=$(mktemp -d) node-gyp rebuild --nodedir=${electron.headers} + popd + + substituteInPlace scripts/generate-protos.sh \ + --replace-fail "/usr/bin/env" "${coreutils}/bin/env" + cp -r ${anytype-heart}/lib dist/ cp -r ${anytype-heart}/bin/anytypeHelper dist/ + # Without this, build fails when trying to copy/write into that directory during the js bundle step + chmod -R u+w dist/ + + bash ./scripts/generate-protos.sh --from-dist + + bun run build + for lang in ${finalAttrs.locales}/locales/*; do cp "$lang" "dist/lib/json/lang/$(basename $lang)" done - npm run build - npm run build:nmh + # $HOME/.cache/go-build. + export GOCACHE=$(mktemp -d) + # Runs "go build -o dist/nativeMessagingHost ./go/nativeMessagingHost.go" + bun run build:nmh runHook postBuild ''; # remove unnecessary files preInstall = '' - npm prune --omit=dev - chmod u+w -R dist + chmod u+w -R dist node_modules find -type f \( -name "*.ts" -o -name "*.map" \) -exec rm -rf {} + ''; @@ -103,7 +190,7 @@ buildNpmPackage (finalAttrs: { --add-flags ${lib.escapeShellArg commandLineArgs} wrapProgram $out/lib/anytype/dist/nativeMessagingHost \ - --prefix PATH : ${lib.makeBinPath [ lsof ]} + --prefix PATH : ${lib.makeBinPath [ lsof ]} runHook postInstall '';