1{
2 lib,
3 stdenv,
4 callPackage,
5 fetchurl,
6 guile_1_8,
7 xmodmap,
8 which,
9 freetype,
10 libjpeg,
11 sqlite,
12 texliveSmall ? null,
13 aspell ? null,
14 git ? null,
15 python3 ? null,
16 cmake,
17 pkg-config,
18 wrapQtAppsHook,
19 xdg-utils,
20 qtbase,
21 qtsvg,
22 qtmacextras,
23 fetchpatch,
24 ghostscriptX ? null,
25 extraFonts ? false,
26 chineseFonts ? false,
27 japaneseFonts ? false,
28 koreanFonts ? false,
29}:
30
31let
32 pname = "texmacs";
33 version = "2.1.4";
34 common = callPackage ./common.nix {
35 inherit
36 extraFonts
37 chineseFonts
38 japaneseFonts
39 koreanFonts
40 ;
41 tex = texliveSmall;
42 };
43in
44stdenv.mkDerivation {
45 inherit pname version;
46
47 src = fetchurl {
48 url = "https://www.texmacs.org/Download/ftp/tmftp/source/TeXmacs-${version}-src.tar.gz";
49 hash = "sha256-h6aSLuDdrAtVzOnNVPqMEWX9WLDHtkCjPy9JXWnBgYY=";
50 };
51
52 postPatch = common.postPatch + ''
53 substituteInPlace configure \
54 --replace "-mfpmath=sse -msse2" ""
55 '';
56
57 nativeBuildInputs = [
58 guile_1_8
59 pkg-config
60 wrapQtAppsHook
61 xdg-utils
62 cmake
63 ];
64
65 buildInputs = [
66 guile_1_8
67 qtbase
68 qtsvg
69 ghostscriptX
70 freetype
71 libjpeg
72 sqlite
73 git
74 python3
75 ]
76 ++ lib.optionals stdenv.hostPlatform.isDarwin [
77 qtmacextras
78 ];
79
80 patches = [
81 (fetchpatch {
82 name = "fix-compile-clang-19.5.patch";
83 url = "https://github.com/texmacs/texmacs/commit/e72783b023f22eaa0456d2e4cc76ae509d963672.patch";
84 hash = "sha256-oJCiXWTY89BdxwbgtFvfThid0WM83+TAUThSihfr0oA=";
85 })
86 ];
87
88 cmakeFlags = lib.optionals stdenv.hostPlatform.isDarwin [
89 (lib.cmakeFeature "TEXMACS_GUI" "Qt")
90 (lib.cmakeFeature "CMAKE_INSTALL_PREFIX" "./TeXmacs.app/Contents/Resources")
91 ];
92
93 env.NIX_LDFLAGS = "-lz";
94
95 postInstall = lib.optionalString stdenv.hostPlatform.isDarwin ''
96 mkdir -p $out/{Applications,bin}
97 mv TeXmacs.app $out/Applications/
98 makeWrapper $out/Applications/TeXmacs.app/Contents/MacOS/TeXmacs $out/bin/texmacs
99 '';
100
101 qtWrapperArgs = [
102 "--suffix"
103 "PATH"
104 ":"
105 (lib.makeBinPath [
106 xmodmap
107 which
108 ghostscriptX
109 aspell
110 texliveSmall
111 git
112 python3
113 ])
114 ];
115
116 postFixup = lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
117 wrapQtApp $out/bin/texmacs
118 '';
119
120 meta = common.meta // {
121 maintainers = [ lib.maintainers.roconnor ];
122 platforms = lib.platforms.all;
123 };
124}