gnu: Add fcitx5-chinese-addons.
[jackhill/guix/guix.git] / gnu / packages / fcitx5.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2020 Zhu Zihao <all_but_last@163.com>
3 ;;;
4 ;;; This file is part of GNU Guix.
5 ;;;
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
10 ;;;
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19 (define-module (gnu packages fcitx5)
20 #:use-module (guix packages)
21 #:use-module (guix download)
22 #:use-module (guix build-system cmake)
23 #:use-module ((guix licenses) #:prefix license:)
24 #:use-module (gnu packages boost)
25 #:use-module (gnu packages curl)
26 #:use-module (gnu packages datastructures)
27 #:use-module (gnu packages enchant)
28 #:use-module (gnu packages freedesktop)
29 #:use-module (gnu packages gcc)
30 #:use-module (gnu packages gettext)
31 #:use-module (gnu packages glib)
32 #:use-module (gnu packages gtk)
33 #:use-module (gnu packages iso-codes)
34 #:use-module (gnu packages kde-frameworks)
35 #:use-module (gnu packages libevent)
36 #:use-module (gnu packages linux)
37 #:use-module (gnu packages lua)
38 #:use-module (gnu packages pkg-config)
39 #:use-module (gnu packages pretty-print)
40 #:use-module (gnu packages python)
41 #:use-module (gnu packages qt)
42 #:use-module (gnu packages textutils)
43 #:use-module (gnu packages unicode)
44 #:use-module (gnu packages web)
45 #:use-module (gnu packages xdisorg)
46 #:use-module (gnu packages xml)
47 #:use-module (gnu packages xorg))
48
49 (define-public xcb-imdkit
50 (package
51 (name "xcb-imdkit")
52 (version "1.0.1")
53 (source
54 (origin
55 (method url-fetch)
56 (uri (string-append
57 "https://download.fcitx-im.org/fcitx5/xcb-imdkit/xcb-imdkit-"
58 version ".tar.xz"))
59 (sha256
60 (base32 "1qgbbp8y8ci7haz99vgbrgpjsbrwwyjianyhdvxcirnbm5bybvmz"))
61 (modules '((guix build utils)))
62 (snippet
63 '(begin
64 ;; Remove bundled uthash.
65 (delete-file-recursively "uthash")
66 #t))))
67 (build-system cmake-build-system)
68 (inputs
69 `(("uthash" ,uthash)
70 ("libxcb" ,libxcb)
71 ("xcb-util" ,xcb-util)
72 ("xcb-util-keysyms" ,xcb-util-keysyms)))
73 (native-inputs
74 `(("extra-cmake-modules" ,extra-cmake-modules)
75 ("pkg-config" ,pkg-config)))
76 (home-page "https://github.com/fcitx/xcb-imdkit")
77 (synopsis "Input method development support for XCB")
78 (description "Xcb-imdkit is an implementation of xim protocol in XCB,
79 comparing with the implementation of IMDkit with Xlib, and xim inside Xlib, it
80 has less memory foot print, better performance, and safer on malformed
81 client.")
82 (license license:lgpl2.1)))
83
84 (define-public fcitx5
85 (package
86 (name "fcitx5")
87 (version "5.0.3")
88 (source
89 (origin
90 (method url-fetch)
91 (uri (string-append
92 "https://download.fcitx-im.org/fcitx5/fcitx5/fcitx5-"
93 version "_dict.tar.xz"))
94 (sha256
95 (base32 "06zkb33m2rnhg385iy79n3r4svz5jbav74di61xqa3lhbv7534s3"))))
96 (build-system cmake-build-system)
97 (arguments
98 `(#:configure-flags
99 (list (string-append "-DCLDR_DIR="
100 (assoc-ref %build-inputs "unicode-cldr-common")
101 "/share/unicode/cldr"))))
102 (inputs
103 `(("cairo" ,cairo)
104 ("cairo-xcb" ,cairo-xcb)
105 ("dbus" ,dbus)
106 ("enchant" ,enchant)
107 ("expat" ,expat)
108 ("fmt" ,fmt)
109 ("gdk-pixbuf" ,gdk-pixbuf)
110 ("gettext" ,gettext-minimal)
111 ("glib" ,glib)
112 ("iso-codes" ,iso-codes)
113 ("json-c" ,json-c)
114 ("libevent" ,libevent)
115 ("libpthread-stubs" ,libpthread-stubs)
116 ("libuuid" ,util-linux "lib")
117 ("libx11" ,libx11)
118 ("libxcb" ,libxcb)
119 ("libxfixes" ,libxfixes)
120 ("libxinerama" ,libxinerama)
121 ("libxkbcommon" ,libxkbcommon)
122 ("libxkbfile" ,libxkbfile)
123 ("pango" ,pango)
124 ("unicode-cldr-common" ,unicode-cldr-common)
125 ("wayland" ,wayland)
126 ("wayland-protocols" ,wayland-protocols)
127 ("xcb-imdkit" ,xcb-imdkit)
128 ("xcb-util" ,xcb-util)
129 ("xcb-util-keysyms" ,xcb-util-keysyms)
130 ("xcb-util-wm" ,xcb-util-wm)
131 ("xkeyboard-config" ,xkeyboard-config)))
132 (native-inputs
133 `(("extra-cmake-modules" ,extra-cmake-modules)
134 ("pkg-config" ,pkg-config)))
135 (native-search-paths
136 (list (search-path-specification
137 (variable "FCITX_ADDON_DIRS")
138 (files '("lib/fcitx5")))))
139 (home-page "https://github.com/fcitx/fcitx5")
140 (synopsis "Input method framework")
141 (description "Fcitx 5 is a generic input method framework.")
142 (license license:lgpl2.1+)))
143
144 (define-public fcitx5-lua
145 (package
146 (name "fcitx5-lua")
147 (version "5.0.1")
148 (source
149 (origin
150 (method url-fetch)
151 (uri (string-append
152 "https://download.fcitx-im.org/fcitx5/fcitx5-lua/fcitx5-lua-"
153 version ".tar.xz"))
154 (sha256
155 (base32 "177mj56j8yrl79hvk7bbrifvm137np23pwalv83ibgk4l51z92hf"))))
156 (build-system cmake-build-system)
157 (arguments
158 `(#:configure-flags
159 (list
160 (string-append "-DFEM_INCLUDE_INSTALL_DIR=" %output "/include")
161 (string-append "-DFEM_LIB_INSTALL_DIR=" %output "/lib"))
162 #:phases
163 (modify-phases %standard-phases
164 (add-before 'configure 'patch-install-prefix
165 (lambda* (#:key outputs #:allow-other-keys)
166 (for-each
167 (lambda (x)
168 (format #t "patch-install-prefix: Fixing install prefix in ~a~%"
169 x)
170 (substitute* x
171 (("\\$\\{FCITX_INSTALL_PKGDATADIR\\}")
172 (string-append (assoc-ref outputs "out")
173 "/share/fcitx5"))))
174 '("src/addonloader/CMakeLists.txt"
175 "src/imeapi/CMakeLists.txt")))))))
176 (inputs
177 `(("fcitx5" ,fcitx5)
178 ("lua" ,lua)
179 ("gettext" ,gettext-minimal)
180 ("libpthread-stubs" ,libpthread-stubs)))
181 (native-inputs
182 `(("extra-cmake-modules" ,extra-cmake-modules)))
183 (home-page "https://github.com/fcitx/fcitx5-lua")
184 (synopsis "Lua support for Fcitx 5")
185 (description "Fcitx5-lua allows writing Fcitx5 extension in Lua.")
186 (license license:lgpl2.1+)))
187
188 (define-public libime
189 (package
190 (name "libime")
191 (version "1.0.2")
192 (source
193 (origin
194 (method url-fetch)
195 (uri (string-append "https://download.fcitx-im.org/fcitx5/libime/libime-"
196 version "_dict.tar.xz"))
197 (sha256
198 (base32 "006pncby7p6h3rnicckzjwi6jzsrqiqbj6p9bpic80lanlllgw31"))))
199 (build-system cmake-build-system)
200 (inputs
201 `(("fcitx5" ,fcitx5)
202 ("boost" ,boost)))
203 (native-inputs
204 `(("gcc" ,gcc-9) ;for #include <filesystem> and ld support
205 ("extra-cmake-modules" ,extra-cmake-modules)
206 ("python" ,python))) ;needed to run test
207 (home-page "https://github.com/fcitx/libime")
208 (synopsis "Library for implementing generic input method")
209 (description "Libime is a library for implmenting various input methods
210 editors.")
211 (license license:lgpl2.1+)))
212
213 (define-public fcitx5-gtk
214 (package
215 (name "fcitx5-gtk")
216 (version "5.0.1")
217 (source
218 (origin
219 (method url-fetch)
220 (uri (string-append "https://download.fcitx-im.org/fcitx5"
221 "/fcitx5-gtk/fcitx5-gtk-"
222 version ".tar.xz"))
223 (sha256
224 (base32 "0h53liraqc5nz4nyi3ixdfdw3zzkdcsiff7j25acc3gmaa5gyij7"))))
225 (build-system cmake-build-system)
226 (arguments
227 `(#:tests? #f ;No test
228 #:configure-flags
229 (list (string-append "-DGOBJECT_INTROSPECTION_GIRDIR="
230 %output "/share/gir-1.0")
231 (string-append "-DGOBJECT_INTROSPECTION_TYPELIBDIR="
232 %output "/lib/girepository-1.0"))
233 #:phases
234 (modify-phases %standard-phases
235 (add-before 'configure 'patch-install-prefix
236 (lambda* (#:key outputs #:allow-other-keys)
237 (let ((out (assoc-ref outputs "out"))
238 (gtk2 (assoc-ref outputs "gtk2")))
239 ;; Install GTK+ 2 input method module to its own output.
240 (substitute* "gtk2/CMakeLists.txt"
241 (("\\$\\{CMAKE_INSTALL_LIBDIR\\}")
242 (string-append gtk2 "/lib")))))))))
243 (inputs
244 `(("fcitx5" ,fcitx5)
245 ("libxkbcommon" ,libxkbcommon)
246 ("gobject-introspection" ,gobject-introspection)
247 ("gtk2" ,gtk+-2)
248 ("gtk3" ,gtk+)
249 ("glib" ,glib)
250 ("libx11" ,libx11)
251 ("gettext" ,gettext-minimal)))
252 (native-inputs
253 `(("extra-cmake-modules" ,extra-cmake-modules)
254 ("pkg-config" ,pkg-config)
255 ("glib" ,glib "bin"))) ;for glib-genmarshal
256 ;; TODO: Add "lib" output to reduce the closure size of "gtk2".
257 (outputs '("out" "gtk2"))
258 (home-page "https://github.com/fcitx/fcitx5-gtk")
259 (synopsis "Glib based D-Bus client and GTK IM module for Fcitx 5")
260 (description "Fcitx5-gtk provides a Glib based D-Bus client and IM module
261 for GTK+2/GTK+3 application.")
262 (license license:lgpl2.1+)))
263
264 (define-public fcitx5-qt
265 (package
266 (name "fcitx5-qt")
267 (version "5.0.1")
268 (source
269 (origin
270 (method url-fetch)
271 (uri (string-append "https://download.fcitx-im.org/fcitx5"
272 "/fcitx5-qt/fcitx5-qt-"
273 version ".tar.xz"))
274 (sha256
275 (base32 "0ilhb4yw9k3m1c4fidnv3nd5dgm9xxds11dgdys6gswjjnmcgqqm"))))
276 (build-system cmake-build-system)
277 (arguments
278 `(#:configure-flags
279 (list (string-append "-DCMAKE_INSTALL_QT5PLUGINDIR="
280 %output "/lib/qt5/plugins")
281 "-DENABLE_QT4=Off")))
282 (inputs
283 `(("fcitx5" ,fcitx5)
284 ("libxcb" ,libxcb)
285 ("libxkbcommon" ,libxkbcommon)
286 ("qtbase" ,qtbase)
287 ("gettext" ,gettext-minimal)))
288 (native-inputs
289 `(("extra-cmake-modules" ,extra-cmake-modules)))
290 (home-page "https://github.com/fcitx/fcitx5-qt")
291 (synopsis "Qt library and IM module for Fcitx 5")
292 (description "Fcitx5-qt provides Qt library for development and IM module
293 for Qt based application.")
294 (license (list license:lgpl2.1+
295 ;; Files under qt4(Fcitx5Qt4DBusAddons), qt5/dbusaddons
296 ;; and qt5/platforminputcontext.
297 license:bsd-3))))
298
299 (define-public fcitx5-chinese-addons
300 (package
301 (name "fcitx5-chinese-addons")
302 (version "5.0.2")
303 (source
304 (origin
305 (method url-fetch)
306 (uri (string-append "https://download.fcitx-im.org/fcitx5"
307 "/fcitx5-chinese-addons/fcitx5-chinese-addons-"
308 version "_dict.tar.xz"))
309 (sha256
310 (base32 "0mf91gzwzhfci0jn6g3l516xjw8r4v40ginnbl70h1zx6vr24rfp"))))
311 (build-system cmake-build-system)
312 (arguments
313 `(#:configure-flags
314 (list
315 (string-append "-DFEM_INCLUDE_INSTALL_DIR=" %output "/include")
316 (string-append "-DFEM_LIB_INSTALL_DIR=" %output "/lib"))
317 #:phases
318 (modify-phases %standard-phases
319 (add-before 'configure 'patch-install-prefix
320 (lambda* (#:key outputs #:allow-other-keys)
321 (for-each
322 (lambda (x)
323 (format #t "patch-install-prefix: Fixing install prefix in ~a~%"
324 x)
325 (substitute* x
326 (("\\$\\{FCITX_INSTALL_PKGDATADIR\\}")
327 (string-append (assoc-ref outputs "out")
328 "/share/fcitx5"))))
329 (find-files "." "CMakeLists\\.txt$"))))
330 (add-before 'configure 'split-outputs
331 ;; Build with GUI supports requires Qt and increase package closure
332 ;; by 800M on x86_64, so place it under another output.
333 (lambda* (#:key outputs #:allow-other-keys)
334 (substitute* "gui/pinyindictmanager/CMakeLists.txt"
335 (("\\$\\{CMAKE_INSTALL_LIBDIR\\}" _)
336 (string-append (assoc-ref outputs "gui") "/lib"))))))))
337 (inputs
338 `(("fcitx5" ,fcitx5)
339 ("fcitx5-lua" ,fcitx5-lua)
340 ("boost" ,boost)
341 ("libime",libime)
342 ("curl" ,curl)
343 ("gettext" ,gettext-minimal)
344 ("fmt" ,fmt)
345 ("libpthread-stubs" ,libpthread-stubs)
346 ("opencc" ,opencc)
347 ("qtbase" ,qtbase)
348 ("fcitx5-qt" ,fcitx5-qt)
349 ("qtwebkit" ,qtwebkit)))
350 (native-inputs
351 `(("extra-cmake-modules" ,extra-cmake-modules)
352 ("pkg-config" ,pkg-config)))
353 (outputs '("out" "gui"))
354 (home-page "https://github.com/fcitx/fcitx5-chinese-addons")
355 (synopsis "Chinese related addons for Fcitx 5")
356 (description "Fcitx5-chinese-addons provides Chinese related addons,
357 including input methods previous bundled inside Fcitx 4:
358
359 @itemize
360 @item Bingchan
361 @item Cangjie
362 @item Erbi
363 @item Pinyin
364 @item Shuangpin
365 @item Wanfeng
366 @item Wubi
367 @item Wubi Pinyin
368 @item Ziranma
369 @end itemize\n")
370 (license (list license:lgpl2.1+
371 license:gpl2+
372 ;; im/pinyin/emoji.txt
373 license:unicode))))