1{
2 lib,
3 fetchFromGitLab,
4 gtksourceview5,
5 libspelling,
6 fetchFromGitHub,
7 python312Packages,
8 nodePackages,
9 meson,
10 ninja,
11 pkg-config,
12 wrapGAppsHook4,
13 desktop-file-utils,
14 gobject-introspection,
15 libadwaita,
16 webkitgtk_6_0,
17 texliveMedium,
18 shared-mime-info,
19 nix-update-script,
20}:
21
22let
23 version = "3.2";
24
25 src = fetchFromGitLab {
26 owner = "World";
27 repo = "apostrophe";
28 domain = "gitlab.gnome.org";
29 rev = "refs/tags/v${version}";
30 hash = "sha256-NPpBu6Wmd8z99vzVQ394CyHRV2RQBtkbuqcaFqKqlkQ=";
31 };
32
33 reveal-js = fetchFromGitHub {
34 owner = "hakimel";
35 repo = "reveal.js";
36
37 # keep in sync with upstream shipped version
38 # in build-aux/flatpak/org.gnome.gitlab.somas.Apostrophe.json
39 rev = "refs/tags/5.1.0";
40 hash = "sha256-L6KVBw20K67lHT07Ws+ZC2DwdURahqyuyjAaK0kTgN0=";
41 };
42in
43
44# Requires telnetlib, and possibly others
45# Try to remove in subsequent updates
46python312Packages.buildPythonApplication {
47 inherit version src;
48 pname = "apostrophe";
49 pyproject = false;
50
51 postPatch = ''
52 substituteInPlace build-aux/meson_post_install.py \
53 --replace-fail 'gtk-update-icon-cache' 'gtk4-update-icon-cache'
54
55 patchShebangs --build build-aux/meson_post_install.py
56 ''
57 # Use mathjax from nixpkgs to avoid loading from CDN
58 + ''
59 substituteInPlace apostrophe/preview_converter.py \
60 --replace-fail "--mathjax" "--mathjax=file://${nodePackages.mathjax}/lib/node_modules/mathjax/es5/tex-chtml-full.js"
61 '';
62
63 # Should be done in postInstall, but meson checks this eagerly before build
64 preConfigure = ''
65 install -d $out/share/apostrophe/libs
66 cp -r ${reveal-js} $out/share/apostrophe/libs/reveal.js
67 '';
68
69 nativeBuildInputs = [
70 meson
71 ninja
72 pkg-config
73 wrapGAppsHook4
74 desktop-file-utils
75 gobject-introspection
76 ];
77
78 buildInputs = [
79 libadwaita
80 gtksourceview5
81 libspelling
82 webkitgtk_6_0
83 ];
84
85 dependencies = with python312Packages; [
86 pygobject3
87 pypandoc
88 chardet
89 levenshtein
90 ];
91
92 dontWrapGApps = true;
93
94 preFixup = ''
95 makeWrapperArgs+=(
96 ''${gappsWrapperArgs[@]}
97 --prefix PATH : "${texliveMedium}/bin"
98 --prefix XDG_DATA_DIRS : "${shared-mime-info}/share"
99 )
100 '';
101
102 passthru = {
103 inherit reveal-js;
104 updateScript = nix-update-script { };
105 };
106
107 meta = {
108 homepage = "https://gitlab.gnome.org/World/apostrophe";
109 description = "Distraction free Markdown editor for GNU/Linux";
110 license = lib.licenses.gpl3Plus;
111 platforms = lib.platforms.linux;
112 maintainers = with lib.maintainers; [
113 sternenseemann
114 ];
115 teams = [ lib.teams.gnome-circle ];
116 mainProgram = "apostrophe";
117 };
118}