anytype: improve local build (#393125)

This commit is contained in:
Austin Horstman 2025-03-28 15:35:45 -05:00 committed by GitHub
commit dc52ceb7eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 8 deletions

View File

@ -1,16 +1,15 @@
{
stdenv,
lib,
callPackage,
fetchFromGitHub,
buildGoModule,
protoc-gen-grpc-web,
protoc-gen-js,
protobuf,
tantivy-go,
}:
let
tantivy-go = callPackage ../tantivy-go { };
pname = "anytype-heart";
version = "0.39.11";
src = fetchFromGitHub {
@ -76,6 +75,9 @@ buildGoModule {
cp LICENSE.md $out/share
'';
# disable tests to save time, as it's mostly built by users, not CI
doCheck = false;
meta = {
description = "Shared library for Anytype clients";
homepage = "https://anytype.io/";

View File

@ -1,10 +1,10 @@
{
lib,
callPackage,
runCommand,
fetchFromGitHub,
buildNpmPackage,
pkg-config,
anytype-heart,
libsecret,
electron,
makeDesktopItem,
@ -14,7 +14,6 @@
}:
let
anytype-heart = callPackage ./anytype-heart { };
pname = "anytype";
version = "0.45.3";
@ -74,13 +73,20 @@ buildNpmPackage {
runHook postBuild
'';
# remove unnecessary files
preInstall = ''
npm prune --omit=dev
chmod u+w -R dist
find -type f \( -name "*.ts" -o -name "*.map" \) -exec rm -rf {} +
'';
installPhase = ''
runHook preInstall
mkdir -p $out/lib/node_modules/anytype
cp -r electron.js electron dist node_modules package.json $out/lib/node_modules/anytype/
mkdir -p $out/lib/anytype
cp -r electron.js electron dist node_modules package.json $out/lib/anytype/
for icon in $out/lib/node_modules/anytype/electron/img/icons/*.png; do
for icon in $out/lib/anytype/electron/img/icons/*.png; do
mkdir -p "$out/share/icons/hicolor/$(basename $icon .png)/apps"
ln -s "$icon" "$out/share/icons/hicolor/$(basename $icon .png)/apps/anytype.png"
done
@ -90,7 +96,7 @@ buildNpmPackage {
makeWrapper '${lib.getExe electron}' $out/bin/anytype \
--set-default ELECTRON_IS_DEV 0 \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \
--add-flags $out/lib/node_modules/anytype/ \
--add-flags $out/lib/anytype/ \
--add-flags ${lib.escapeShellArg commandLineArgs}
runHook postInstall