1{
2 stdenvNoCC,
3 lib,
4 fetchzip,
5 autoPatchelfHook,
6 makeWrapper,
7 copyDesktopItems,
8 makeDesktopItem,
9 gtk3,
10 xdg-user-dirs,
11 keybinder3,
12 libnotify,
13}:
14
15let
16 dist =
17 rec {
18 x86_64-linux = {
19 urlSuffix = "linux-x86_64.tar.gz";
20 hash = "sha256-GhQaT6vby0VD8dPr88JcDLcBX+r0apdOyip3tk30was=";
21 };
22 x86_64-darwin = {
23 urlSuffix = "macos-universal.zip";
24 hash = "sha256-/hj+8okWufI2ow54xCD+XMZiEsPh0jjG8VN/phx+zgs=";
25 };
26 aarch64-darwin = x86_64-darwin;
27 }
28 ."${stdenvNoCC.hostPlatform.system}"
29 or (throw "appflowy: No source for system: ${stdenvNoCC.hostPlatform.system}");
30in
31stdenvNoCC.mkDerivation (finalAttrs: {
32 pname = "appflowy";
33 version = "0.9.5";
34
35 src = fetchzip {
36 url = "https://github.com/AppFlowy-IO/appflowy/releases/download/${finalAttrs.version}/AppFlowy-${finalAttrs.version}-${dist.urlSuffix}";
37 inherit (dist) hash;
38 stripRoot = false;
39 };
40
41 nativeBuildInputs = [
42 makeWrapper
43 copyDesktopItems
44 ]
45 ++ lib.optionals stdenvNoCC.hostPlatform.isLinux [ autoPatchelfHook ];
46
47 buildInputs = [
48 gtk3
49 keybinder3
50 libnotify
51 ];
52
53 dontBuild = true;
54 dontConfigure = true;
55
56 installPhase =
57 lib.optionalString stdenvNoCC.hostPlatform.isLinux ''
58 runHook preInstall
59
60 cd AppFlowy/
61
62 mkdir -p $out/{bin,opt}
63
64 # Copy archive contents to the outpout directory
65 cp -r ./* $out/opt/
66
67 # Copy icon
68 install -Dm444 data/flutter_assets/assets/images/flowy_logo.svg $out/share/icons/hicolor/scalable/apps/appflowy.svg
69
70 runHook postInstall
71 ''
72 + lib.optionalString stdenvNoCC.hostPlatform.isDarwin ''
73 runHook preInstall
74
75 mkdir -p $out/{Applications,bin}
76 cp -r ./AppFlowy.app $out/Applications/
77
78 runHook postInstall
79 '';
80
81 preFixup =
82 lib.optionalString stdenvNoCC.hostPlatform.isLinux ''
83 # Add missing libraries to appflowy using the ones it comes with
84 makeWrapper $out/opt/AppFlowy $out/bin/appflowy \
85 --set LD_LIBRARY_PATH "$out/opt/lib/" \
86 --prefix PATH : "${lib.makeBinPath [ xdg-user-dirs ]}"
87 ''
88 + lib.optionalString stdenvNoCC.hostPlatform.isDarwin ''
89 makeWrapper $out/Applications/AppFlowy.app/Contents/MacOS/AppFlowy $out/bin/appflowy
90 '';
91
92 desktopItems = lib.optionals stdenvNoCC.hostPlatform.isLinux [
93 (makeDesktopItem {
94 name = "appflowy";
95 desktopName = "AppFlowy";
96 comment = finalAttrs.meta.description;
97 exec = "appflowy %U";
98 icon = "appflowy";
99 categories = [ "Office" ];
100 mimeTypes = [ "x-scheme-handler/appflowy-flutter" ];
101 })
102 ];
103
104 meta = with lib; {
105 description = "Open-source alternative to Notion";
106 homepage = "https://www.appflowy.io/";
107 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
108 license = licenses.agpl3Only;
109 changelog = "https://github.com/AppFlowy-IO/appflowy/releases/tag/${finalAttrs.version}";
110 maintainers = with maintainers; [ darkonion0 ];
111 platforms = [ "x86_64-linux" ] ++ platforms.darwin;
112 mainProgram = "appflowy";
113 };
114})