nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 qt6Packages,
6 cmake,
7 makeWrapper,
8 botan3,
9 libgit2,
10 pkg-config,
11 nixosTests,
12 installShellFiles,
13 xvfb-run,
14 versionCheckHook,
15 nix-update-script,
16 aspell,
17}:
18
19stdenv.mkDerivation (finalAttrs: {
20 pname = "qownnotes";
21 appname = "QOwnNotes";
22 version = "26.1.11";
23
24 src = fetchurl {
25 url = "https://github.com/pbek/QOwnNotes/releases/download/v${finalAttrs.version}/qownnotes-${finalAttrs.version}.tar.xz";
26 hash = "sha256-07l/ma8FkvnRBgEo8j6dkbdqm3oqyCf3CVKvt+0nzsQ=";
27 };
28
29 nativeBuildInputs = [
30 cmake
31 qt6Packages.qttools
32 qt6Packages.wrapQtAppsHook
33 pkg-config
34 installShellFiles
35 ]
36 ++ lib.optionals stdenv.hostPlatform.isLinux [ xvfb-run ]
37 ++ lib.optionals stdenv.hostPlatform.isDarwin [ makeWrapper ];
38
39 buildInputs = [
40 qt6Packages.qtbase
41 qt6Packages.qtdeclarative
42 qt6Packages.qtsvg
43 qt6Packages.qtwebsockets
44 botan3
45 libgit2
46 aspell
47 ]
48 ++ lib.optionals stdenv.hostPlatform.isLinux [ qt6Packages.qtwayland ];
49
50 cmakeFlags = [
51 "-DQON_QT6_BUILD=ON"
52 "-DBUILD_WITH_SYSTEM_BOTAN=ON"
53 "-DBUILD_WITH_LIBGIT2=ON"
54 "-DBUILD_WITH_ASPELL=ON"
55 ];
56
57 # Install shell completion on Linux (with xvfb-run)
58 postInstall =
59 lib.optionalString stdenv.hostPlatform.isLinux ''
60 installShellCompletion --cmd ${finalAttrs.appname} \
61 --bash <(xvfb-run $out/bin/${finalAttrs.appname} --completion bash) \
62 --fish <(xvfb-run $out/bin/${finalAttrs.appname} --completion fish)
63 installShellCompletion --cmd ${finalAttrs.pname} \
64 --bash <(xvfb-run $out/bin/${finalAttrs.appname} --completion bash) \
65 --fish <(xvfb-run $out/bin/${finalAttrs.appname} --completion fish)
66 ''
67 # Install shell completion on macOS
68 + lib.optionalString stdenv.hostPlatform.isDarwin ''
69 installShellCompletion --cmd ${finalAttrs.pname} \
70 --bash <($out/bin/${finalAttrs.appname} --completion bash) \
71 --fish <($out/bin/${finalAttrs.appname} --completion fish)
72 ''
73 # Create a lowercase symlink for Linux
74 + lib.optionalString stdenv.hostPlatform.isLinux ''
75 ln -s $out/bin/${finalAttrs.appname} $out/bin/${finalAttrs.pname}
76 ''
77 # Rename application for macOS as lowercase binary
78 + lib.optionalString stdenv.hostPlatform.isDarwin ''
79 # Prevent "same file" error
80 mv $out/bin/${finalAttrs.appname} $out/bin/${finalAttrs.pname}.bin
81 mv $out/bin/${finalAttrs.pname}.bin $out/bin/${finalAttrs.pname}
82 '';
83
84 # Tests QOwnNotes using the NixOS module by launching xterm:
85 passthru.tests.basic-nixos-module-functionality = nixosTests.qownnotes;
86
87 nativeInstallCheckInputs = [
88 versionCheckHook
89 ];
90 doInstallCheck = true;
91
92 passthru = {
93 updateScript = nix-update-script { };
94 };
95
96 meta = {
97 description = "Plain-text file notepad and todo-list manager with markdown support and Nextcloud/ownCloud integration";
98 homepage = "https://www.qownnotes.org/";
99 changelog = "https://www.qownnotes.org/changelog.html";
100 downloadPage = "https://github.com/pbek/QOwnNotes/releases/tag/v${finalAttrs.version}";
101 license = lib.licenses.gpl2Only;
102 maintainers = with lib.maintainers; [
103 pbek
104 totoroot
105 matthiasbeyer
106 ];
107 platforms = lib.platforms.unix;
108 mainProgram = "qownnotes";
109 };
110})