anytype: 0.54.11 -> 0.55.5

Co-authored-by: xmnlz <lemmeq9@gmail.com>
This commit is contained in:
Michal Koutenský 2026-05-16 15:55:44 +02:00
commit 2684678b1e
2 changed files with 109 additions and 27 deletions

View file

@ -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

View file

@ -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, thats clonefile and on Linux, thats 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
'';