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