gnu: Add Norwegian Nynorsk Aspell dictionary.
[jackhill/guix/guix.git] / gnu / packages / aspell.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2014, 2015, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2015, 2016 Alex Kost <alezost@gmail.com>
4 ;;; Copyright © 2016 John Darrington <jmd@gnu.org>
5 ;;; Copyright © 2016, 2017, 2019 Efraim Flashner <efraim@flashner.co.il>
6 ;;; Copyright © 2016 Christopher Andersson <christopher@8bits.nu>
7 ;;; Copyright © 2016 Theodoros Foradis <theodoros@foradis.org>
8 ;;; Copyright © 2016, 2017, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
9 ;;; Copyright © 2019 Jens Mølgaard <jens@zete.tk>
10 ;;;
11 ;;; This file is part of GNU Guix.
12 ;;;
13 ;;; GNU Guix is free software; you can redistribute it and/or modify it
14 ;;; under the terms of the GNU General Public License as published by
15 ;;; the Free Software Foundation; either version 3 of the License, or (at
16 ;;; your option) any later version.
17 ;;;
18 ;;; GNU Guix is distributed in the hope that it will be useful, but
19 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;;; GNU General Public License for more details.
22 ;;;
23 ;;; You should have received a copy of the GNU General Public License
24 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
25
26 (define-module (gnu packages aspell)
27 #:use-module (guix packages)
28 #:use-module (guix download)
29 #:use-module (guix build-system gnu)
30 #:use-module (guix licenses)
31 #:use-module (guix utils)
32 #:use-module (gnu packages)
33 #:use-module (gnu packages base)
34 #:use-module (gnu packages compression)
35 #:use-module (gnu packages perl))
36
37 (define-public aspell
38 (package
39 (name "aspell")
40 (version "0.60.6.1")
41 (source
42 (origin
43 (method url-fetch)
44 (uri (string-append "mirror://gnu/aspell/aspell-"
45 version ".tar.gz"))
46 (sha256
47 (base32
48 "1qgn5psfyhbrnap275xjfrzppf5a83fb67gpql0kfqv37al869gm"))
49 (patches (search-patches "aspell-default-dict-dir.patch"))))
50 (build-system gnu-build-system)
51 (arguments
52 `(#:phases
53 (modify-phases %standard-phases
54 (add-before 'build 'set-filter-path
55 (lambda* (#:key outputs #:allow-other-keys)
56 ;; Change the default value of 'filter-path' so that filters such
57 ;; as 'tex-filter.so' can be found. By default none of the
58 ;; filters would be found.
59 (let* ((out (assoc-ref outputs "out"))
60 (libdir (string-append out "/lib/aspell-"
61 ,(version-major+minor version))))
62 (substitute* "common/config.cpp"
63 (("\"filter-path(.*)DICT_DIR" _ middle)
64 (string-append "\"filter-path" middle
65 "\"" libdir "\"")))
66 #t)))
67 (add-after 'install 'wrap-aspell
68 (lambda* (#:key outputs #:allow-other-keys)
69 (let ((bin/aspell (string-append (assoc-ref outputs "out")
70 "/bin/aspell")))
71 (wrap-program bin/aspell
72 '("ASPELL_CONF" "" =
73 ("${ASPELL_CONF:-\"dict-dir ${GUIX_PROFILE:-$HOME/.guix-profile}/lib/aspell\"}")))
74 #t))))))
75 (inputs `(("perl" ,perl)))
76
77 (native-search-paths
78 ;; This is a Guix-specific environment variable that takes a single
79 ;; entry, not an actual search path.
80 (list (search-path-specification
81 (variable "ASPELL_DICT_DIR")
82 (separator #f)
83 (files '("lib/aspell")))))
84
85 (home-page "http://aspell.net/")
86 (synopsis "Spell checker")
87 (description
88 "Aspell is a spell-checker which can be used either as a library or as
89 a standalone program. Notable features of Aspell include its full support of
90 documents written in the UTF-8 encoding and its ability to use multiple
91 dictionaries, including personal ones.")
92 (license lgpl2.1+)))
93
94 ;;;
95 ;;; Dictionaries.
96 ;;;
97 ;;; Use 'export ASPELL_CONF="dict-dir $HOME/.guix-profile/lib/aspell"' to use
98 ;;; them, or set the Guix-specific 'ASPELL_DICT_DIR', or just do nothing (as
99 ;;; long as 'HOME' is set, that's fine!).
100 ;;;
101
102 (define* (aspell-dictionary dict-name full-name
103 #:key version sha256 (prefix "aspell6-"))
104 (package
105 (name (string-append "aspell-dict-" dict-name))
106 (version version)
107 (source (origin
108 (method url-fetch)
109 (uri (string-append "mirror://gnu/aspell/dict/" dict-name
110 "/" prefix dict-name "-"
111 version ".tar.bz2"))
112 (sha256 sha256)))
113 (build-system gnu-build-system)
114 (arguments
115 `(#:phases
116 (modify-phases %standard-phases
117 (replace 'configure
118 (lambda* (#:key outputs #:allow-other-keys)
119 (let ((out (assoc-ref outputs "out")))
120 (invoke "./configure")))))
121 #:make-flags
122 (let ((out (assoc-ref %outputs "out")))
123 (list (string-append "dictdir=" out "/lib/aspell")
124 (string-append "datadir=" out "/lib/aspell")))
125 #:tests? #f))
126 (native-inputs `(("aspell" ,aspell)
127 ("which" ,which)))
128 (synopsis (string-append full-name " dictionary for GNU Aspell")) ; XXX: i18n
129 (description
130 "This package provides a dictionary for the GNU Aspell spell checker.")
131 (license gpl2+)
132 (home-page "http://aspell.net/")))
133
134
135 (define-public aspell-dict-ar
136 (aspell-dictionary "ar" "Arabic"
137 #:version "1.2-0"
138 #:prefix "aspell6-"
139 #:sha256
140 (base32
141 "1avw40bp8yi5bnkq64ihm2rldgw34lk89yz281q9bmndh95a47h4")))
142
143 (define-public aspell-dict-be
144 (aspell-dictionary "be" "Belarusian"
145 #:version "0.01"
146 #:prefix "aspell5-"
147 #:sha256
148 (base32
149 "1svls9p7rsfi3hs0afh0cssj006qb4v1ik2yzqgj8hm10c6as2sm")))
150
151 (define-public aspell-dict-ca
152 (aspell-dictionary "ca" "Catalan"
153 #:version "2.1.5-1"
154 #:sha256
155 (base32
156 "1fb5y5kgvk25nlsfvc8cai978hg66x3pbp9py56pldc7vxzf9npb")))
157
158 (define-public aspell-dict-de
159 (aspell-dictionary "de" "German"
160 #:version "20030222-1"
161 #:sha256
162 (base32
163 "01p92qj66cqb346gk7hjfynaap5sbcn85xz07kjfdq623ghr8v5s")))
164
165 (define-public aspell-dict-da
166 (aspell-dictionary "da" "Danish"
167 #:version "1.4.42-1"
168 #:prefix "aspell5-"
169 #:sha256
170 (base32
171 "1hfkmiyhgrx5lgrb2mffjbdn1hivrm73wcg7x0iid74p2yb0fjpp")))
172
173 (define-public aspell-dict-el
174 (aspell-dictionary "el" "Greek"
175 #:version "0.08-0"
176 #:prefix "aspell6-"
177 #:sha256
178 (base32
179 "1ljcc30zg2v2h3w5h5jr5im41mw8jbsgvvhdd2cii2yzi8d0zxja")))
180
181 (define-public aspell-dict-en
182 (aspell-dictionary "en" "English"
183 #:version "2018.04.16-0"
184 #:sha256
185 (base32
186 "0bxxdzkk9g27plg22y9qzsx9cfjw3aa29w5bmzs561qc9gkp247i")))
187
188 (define-public aspell-dict-eo
189 (aspell-dictionary "eo" "Esperanto"
190 #:version "2.1.20000225a-2"
191 #:sha256
192 (base32
193 "09vf0mbiicbmyb4bwb7v7lgpabnylg0wy7m3hlhl5rjdda6x3lj1")))
194
195 (define-public aspell-dict-es
196 (aspell-dictionary "es" "Spanish"
197 #:version "1.11-2"
198 #:sha256
199 (base32
200 "1k5g328ac1hdpp6fsg57d8md6i0aqcwlszp3gbmp5706wyhpydmd")))
201
202 (define-public aspell-dict-fi
203 (aspell-dictionary "fi" "Finnish"
204 #:version "0.7-0"
205 #:prefix "aspell6-"
206 #:sha256
207 (base32
208 "07d5s08ba4dd89cmwy9icc01i6fjdykxlb9ravmhdrhi8mxz1mzq")))
209
210 (define-public aspell-dict-fr
211 (aspell-dictionary "fr" "French"
212 #:version "0.50-3"
213 #:prefix "aspell-"
214 #:sha256
215 (base32
216 "14ffy9mn5jqqpp437kannc3559bfdrpk7r36ljkzjalxa53i0hpr")))
217
218 (define-public aspell-dict-grc
219 (aspell-dictionary "grc" "Ancient Greek"
220 #:version "0.02-0"
221 #:sha256
222 (base32
223 "1zxr8958v37v260fkqd4pg37ns5h5kyqm54hn1hg70wq5cz8h512")))
224
225 (define-public aspell-dict-he
226 (aspell-dictionary "he" "Hebrew"
227 #:version "1.0-0"
228 #:sha256
229 (base32
230 "13bhbghx5b8g0119g3wxd4n8mlf707y41vlf59irxjj0kynankfn")))
231
232 (define-public aspell-dict-hi
233 (aspell-dictionary "hi" "Hindi"
234 #:version "0.02-0"
235 #:prefix "aspell6-"
236 #:sha256
237 (base32
238 "0drs374qz4419zx1lf2k281ydxf2750jk5ailafj1x0ncz27h1ys")))
239
240 (define-public aspell-dict-it
241 (let ((version "2.4-20070901-0")
242 (sha256
243 (base32 "0d6ypii3jblprpibazb6ypady536jz62rwxlss1x1raq07rhvvqn")))
244 (package
245 (inherit (aspell-dictionary "it" "Italian"
246 #:version version
247 #:sha256 sha256))
248
249 ;; The version hosted at <https://ftp.gnu.org/gnu/aspell/dict> is even
250 ;; more out of date.
251 (source
252 (origin
253 (method url-fetch)
254 (uri (string-append "mirror://sourceforge/linguistico/"
255 "Dizionario%20italiano%20per%20Aspell/" version "/"
256 "aspell6-it-" version ".tar.bz2"))
257 (sha256 sha256)))
258 (home-page
259 "http://linguistico.sourceforge.net/pages/dizionario_italiano.html"))))
260
261 (define-public aspell-dict-mi
262 (aspell-dictionary "mi" "Maori"
263 #:version "0.50-0"
264 #:sha256
265 (base32
266 "12bxplpd348yx8d2q8qvahi9dlp7qf28qmanzhziwc7np8rixvmy")))
267
268 (define-public aspell-dict-nl
269 (aspell-dictionary "nl" "Dutch"
270 #:version "0.50-2"
271 #:prefix "aspell-"
272 #:sha256
273 (base32
274 "0ffb87yjsh211hllpc4b9khqqrblial4pzi1h9r3v465z1yhn3j4")))
275
276 (define-public aspell-dict-nn
277 (aspell-dictionary "nn" "Norwegian Nynorsk"
278 #:version "0.50.1-1"
279 #:sha256
280 (base32
281 "0w2k5l5rbqpliripgqwiqixz5ghnjf7i9ggbrc4ly4vy1ia10rmc")))
282
283 (define-public aspell-dict-pt-br
284 (aspell-dictionary "pt-br" "Brazilian Portuguese"
285 #:version "20090702-0"
286 #:prefix "aspell6-"
287 #:sha256
288 (base32
289 "1y09lx9zf2rnp55r16b2vgj953l3538z1vaqgflg9mdvm555bz3p")))
290
291 (define-public aspell-dict-ru
292 (aspell-dictionary "ru" "Russian"
293 #:version "0.99f7-1"
294 #:sha256
295 (base32
296 "0ip6nq43hcr7vvzbv4lwwmlwgfa60hrhsldh9xy3zg2prv6bcaaw")))
297
298 (define-public aspell-dict-sv
299 (aspell-dictionary "sv" "Swedish"
300 #:version "0.51-0"
301 #:prefix "aspell-"
302 #:sha256
303 (base32
304 "02jwkjhr32kvyibnyzgx3smbnm576jwdzg3avdf6zxwckhy5fw4v")))
305
306 \f
307 ;;;
308 ;;; Hunspell packages made from the Aspell word lists.
309 ;;;
310
311 (define* (aspell-word-list language synopsis
312 #:optional
313 (nick (string-map (lambda (chr)
314 (if (char=? #\_ chr)
315 #\-
316 chr))
317 (string-downcase language))))
318 (package
319 (name (string-append "hunspell-dict-" nick))
320 (version "2018.04.16")
321 (source (origin
322 (method url-fetch)
323 (uri (string-append
324 "http://downloads.sourceforge.net/wordlist/scowl-"
325 version ".tar.gz"))
326 (sha256
327 (base32
328 "11lkrnhwrf5mvrrq45k4mads3n9aswgac8dc25ba61c75alxb5rs"))))
329 (native-inputs
330 `(("tar" ,tar)
331 ("gzip" ,gzip)
332 ("perl" ,perl)
333 ("aspell" ,aspell)))
334 (build-system gnu-build-system)
335 (arguments
336 `(#:phases
337 (modify-phases %standard-phases
338 (delete 'configure)
339 (delete 'check)
340 (replace 'build
341 (lambda _
342 (substitute* "speller/make-hunspell-dict"
343 (("zip -9 .*$")
344 "return\n"))
345 (mkdir "speller/hunspell")
346
347 ;; XXX: This actually builds all the dictionary variants.
348 (invoke "make" "-C" "speller" "hunspell")))
349 (replace 'install
350 (lambda* (#:key outputs #:allow-other-keys)
351 (let* ((out (assoc-ref %outputs "out"))
352 (hunspell (string-append out "/share/hunspell"))
353 (myspell (string-append out "/share/myspell"))
354 (doc (string-append out "/share/doc/"
355 ,name))
356 (dot-dic ,(string-append "speller/" language ".dic")))
357 (mkdir-p myspell)
358
359 ;; Usually there's only a 'LANGUAGE.dic' file, but for the "en"
360 ;; dictionary, there no 'en.dic'. Instead, there's a set of
361 ;; 'en*.dic' files, hence the 'find-files' call below.
362 (if (file-exists? dot-dic)
363 (install-file dot-dic hunspell)
364 (for-each (lambda (dic)
365 (install-file dic hunspell))
366 (find-files "speller"
367 ,(string-append language ".*\\.dic$"))))
368
369 (install-file ,(string-append "speller/" language ".aff")
370 hunspell)
371 (symlink hunspell (string-append myspell "/dicts"))
372 (for-each (lambda (file)
373 (install-file file doc))
374 (find-files "."
375 "^(Copyright|.*\\.(txt|org|md))$"))
376 #t))))))
377 (synopsis synopsis)
378 (description
379 "This package provides a dictionary for the Hunspell spell-checking
380 library.")
381 (home-page "http://wordlist.aspell.net/")
382 (license (non-copyleft "file://Copyright"
383 "Word lists come from several sources, all
384 under permissive licensing terms. See the 'Copyright' file."))))
385
386 (define-syntax define-word-list-dictionary
387 (syntax-rules (synopsis)
388 ((_ name language (synopsis text))
389 (define-public name
390 (aspell-word-list language text)))
391 ((_ name language nick (synopsis text))
392 (define-public name
393 (aspell-word-list language text nick)))))
394
395 (define-word-list-dictionary hunspell-dict-en
396 "en"
397 (synopsis "Hunspell dictionary for English"))
398
399 (define-word-list-dictionary hunspell-dict-en-au
400 "en_AU"
401 (synopsis "Hunspell dictionary for Australian English"))
402
403 (define-word-list-dictionary hunspell-dict-en-ca
404 "en_CA"
405 (synopsis "Hunspell dictionary for Canadian English"))
406
407 (define-word-list-dictionary hunspell-dict-en-gb
408 "en_GB-ise" "en-gb"
409 (synopsis "Hunspell dictionary for British English, with -ise endings"))
410
411 (define-word-list-dictionary hunspell-dict-en-gb-ize
412 "en_GB-ize"
413 (synopsis "Hunspell dictionary for British English, with -ize endings"))
414
415 (define-word-list-dictionary hunspell-dict-en-us
416 "en_US"
417 (synopsis "Hunspell dictionary for United States English"))