nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 appimageTools,
5 fetchurl,
6 makeWrapper,
7 _7zz,
8}:
9
10let
11 pname = "notesnook";
12 version = "3.3.5";
13
14 inherit (stdenv.hostPlatform) system;
15 throwSystem = throw "Unsupported system: ${system}";
16
17 suffix =
18 {
19 x86_64-linux = "linux_x86_64.AppImage";
20 aarch64-linux = "linux_arm64.AppImage";
21 x86_64-darwin = "mac_x64.dmg";
22 aarch64-darwin = "mac_arm64.dmg";
23 }
24 .${system} or throwSystem;
25
26 src = fetchurl {
27 url = "https://github.com/streetwriters/notesnook/releases/download/v${version}/notesnook_${suffix}";
28 hash =
29 {
30 x86_64-linux = "sha256-jvQph74dMQgino3K1ZFLT/fsJVdTHVqMQaW0RQhfci0=";
31 aarch64-linux = "sha256-jrKmZmdx1T1wrlM0y195Z2MsI1XpFn0gyFyf7N/aUzo=";
32 x86_64-darwin = "sha256-bJ+sq6/lZcLcM7R2KAigemdpRDqSiExfcSunNQ7cGw0=";
33 aarch64-darwin = "sha256-DTY0gq62aXOanZvYletyXl5xmcs30vWTKE4nZujRCq0=";
34 }
35 .${system} or throwSystem;
36 };
37
38 appimageContents = appimageTools.extractType2 {
39 inherit pname version src;
40 };
41
42 meta = {
43 description = "Fully open source & end-to-end encrypted note taking alternative to Evernote";
44 longDescription = ''
45 Notesnook is a free (as in speech) & open source note taking app
46 focused on user privacy & ease of use. To ensure zero knowledge
47 principles, Notesnook encrypts everything on your device using
48 XChaCha20-Poly1305 & Argon2.
49 '';
50 homepage = "https://notesnook.com";
51 license = lib.licenses.gpl3Only;
52 maintainers = with lib.maintainers; [
53 keysmashes
54 ];
55 platforms = [
56 "x86_64-linux"
57 "aarch64-linux"
58 "x86_64-darwin"
59 "aarch64-darwin"
60 ];
61 mainProgram = "notesnook";
62 };
63
64 linux = appimageTools.wrapType2 rec {
65 inherit
66 pname
67 version
68 src
69 meta
70 ;
71
72 nativeBuildInputs = [ makeWrapper ];
73
74 profile = ''
75 export LC_ALL=C.UTF-8
76 '';
77
78 extraInstallCommands = ''
79 wrapProgram $out/bin/notesnook \
80 --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}"
81 install -Dm444 ${appimageContents}/notesnook.desktop -t $out/share/applications
82 install -Dm444 ${appimageContents}/notesnook.png -t $out/share/pixmaps
83 substituteInPlace $out/share/applications/notesnook.desktop \
84 --replace 'Exec=AppRun --no-sandbox %U' 'Exec=${pname}'
85 '';
86 };
87
88 darwin = stdenv.mkDerivation {
89 inherit
90 pname
91 version
92 src
93 meta
94 ;
95
96 nativeBuildInputs = [ _7zz ];
97
98 sourceRoot = "Notesnook.app";
99
100 # 7zz did not unpack in setup hook for some reason, done manually here
101 unpackPhase = ''
102 7zz x $src
103 '';
104
105 installPhase = ''
106 mkdir -p $out/Applications/Notesnook.app
107 cp -R . $out/Applications/Notesnook.app
108 '';
109 };
110in
111if stdenv.hostPlatform.isDarwin then darwin else linux