aspell.scm 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2013, 2014, 2015, 2017, 2018, 2019, 2020 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, 2020 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, 2021 Tobias Geerinckx-Rice <me@tobias.gr>
  9. ;;; Copyright © 2019 Jens Mølgaard <jens@zete.tk>
  10. ;;; Copyright © 2020 Timotej Lazar <timotej.lazar@araneo.si>
  11. ;;; Copyright © 2020 Marcin Karpezo <sirmacik@wioo.waw.pl>
  12. ;;; Copyright © 2020 Jonathan Brielmaier <jonathan.brielmaier@web.de>
  13. ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
  14. ;;; Copyright © 2020 Noah Landis <noahlandis@posteo.net>
  15. ;;; Copyright © 2021 Sergiu Ivanov <sivanov@colimite.fr>
  16. ;;;
  17. ;;; This file is part of GNU Guix.
  18. ;;;
  19. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  20. ;;; under the terms of the GNU General Public License as published by
  21. ;;; the Free Software Foundation; either version 3 of the License, or (at
  22. ;;; your option) any later version.
  23. ;;;
  24. ;;; GNU Guix is distributed in the hope that it will be useful, but
  25. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  26. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. ;;; GNU General Public License for more details.
  28. ;;;
  29. ;;; You should have received a copy of the GNU General Public License
  30. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  31. (define-module (gnu packages aspell)
  32. #:use-module (guix packages)
  33. #:use-module (guix download)
  34. #:use-module (guix build-system gnu)
  35. #:use-module (guix licenses)
  36. #:use-module (guix utils)
  37. #:use-module (gnu packages)
  38. #:use-module (gnu packages base)
  39. #:use-module (gnu packages bison)
  40. #:use-module (gnu packages compression)
  41. #:use-module (gnu packages ncurses)
  42. #:use-module (gnu packages perl)
  43. #:use-module (ice-9 match))
  44. (define-public aspell
  45. (package
  46. (name "aspell")
  47. (version "0.60.8")
  48. (source
  49. (origin
  50. (method url-fetch)
  51. (uri (string-append "mirror://gnu/aspell/aspell-"
  52. version ".tar.gz"))
  53. (sha256
  54. (base32
  55. "1wi60ankalmh8ds7nplz434jd7j94gdvbahdwsr539rlad8pxdzr"))
  56. (patches (search-patches "aspell-default-dict-dir.patch"))))
  57. (build-system gnu-build-system)
  58. (arguments
  59. `(#:phases
  60. (modify-phases %standard-phases
  61. (add-before 'build 'set-filter-path
  62. (lambda* (#:key outputs #:allow-other-keys)
  63. ;; Change the default value of 'filter-path' so that filters such
  64. ;; as 'tex-filter.so' can be found. By default none of the
  65. ;; filters would be found.
  66. (let* ((out (assoc-ref outputs "out"))
  67. (libdir (string-append out "/lib/aspell-"
  68. ,(version-major+minor version))))
  69. (substitute* "common/config.cpp"
  70. (("\"filter-path(.*)DICT_DIR" _ middle)
  71. (string-append "\"filter-path" middle
  72. "\"" libdir "\"")))
  73. #t))))))
  74. (inputs `(("perl" ,perl)))
  75. (native-search-paths
  76. ;; This is a Guix-specific environment variable that takes a single
  77. ;; entry, not an actual search path.
  78. (list (search-path-specification
  79. (variable "ASPELL_DICT_DIR")
  80. (separator #f)
  81. (files '("lib/aspell")))))
  82. (home-page "http://aspell.net/")
  83. (synopsis "Spell checker")
  84. (description
  85. "Aspell is a spell-checker which can be used either as a library or as
  86. a standalone program. Notable features of Aspell include its full support of
  87. documents written in the UTF-8 encoding and its ability to use multiple
  88. dictionaries, including personal ones.")
  89. (license lgpl2.1+)))
  90. ;;;
  91. ;;; Dictionaries.
  92. ;;;
  93. ;;; Use 'export ASPELL_CONF="dict-dir $HOME/.guix-profile/lib/aspell"' to use
  94. ;;; them, or set the Guix-specific 'ASPELL_DICT_DIR', or just do nothing (as
  95. ;;; long as 'HOME' is set, that's fine!).
  96. ;;;
  97. (define* (aspell-dictionary dict-name full-name
  98. #:key version sha256 (prefix "aspell6-"))
  99. (package
  100. (name (string-append
  101. "aspell-dict-"
  102. ;; Downcase and replace underscore in package names
  103. ;; to follow Guix naming conventions.
  104. (string-map (match-lambda
  105. (#\_ #\-)
  106. (chr chr))
  107. (string-downcase dict-name))))
  108. (version version)
  109. (source (origin
  110. (method url-fetch)
  111. (uri (string-append "mirror://gnu/aspell/dict/" dict-name
  112. "/" prefix dict-name "-"
  113. version ".tar.bz2"))
  114. (hash (content-hash sha256))))
  115. (build-system gnu-build-system)
  116. (arguments
  117. `(#:phases
  118. (modify-phases %standard-phases
  119. (replace 'configure
  120. (lambda* (#:key outputs #:allow-other-keys)
  121. (let ((out (assoc-ref outputs "out")))
  122. (invoke "./configure")))))
  123. #:make-flags
  124. (let ((out (assoc-ref %outputs "out")))
  125. (list (string-append "dictdir=" out "/lib/aspell")
  126. (string-append "datadir=" out "/lib/aspell")))
  127. #:tests? #f))
  128. (native-inputs `(("aspell" ,aspell)
  129. ("which" ,which)))
  130. (synopsis (string-append full-name " dictionary for GNU Aspell")) ; XXX: i18n
  131. (description
  132. "This package provides a dictionary for the GNU Aspell spell checker.")
  133. (license gpl2+)
  134. (home-page "http://aspell.net/")))
  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. (define-public aspell-dict-be
  143. (aspell-dictionary "be" "Belarusian"
  144. #:version "0.01"
  145. #:prefix "aspell5-"
  146. #:sha256
  147. (base32
  148. "1svls9p7rsfi3hs0afh0cssj006qb4v1ik2yzqgj8hm10c6as2sm")))
  149. (define-public aspell-dict-ca
  150. (let ((version "2.5.0")
  151. (sha256
  152. (base32 "0kbi8fi7a1bys31kfqrlh332gyik0cfdmxgl7n15sa9c305rkgwq")))
  153. (package
  154. (inherit (aspell-dictionary "ca" "Catalan"
  155. #:version version
  156. #:sha256 sha256))
  157. (source
  158. (origin
  159. (method url-fetch)
  160. (uri (string-append "https://www.softcatala.org/pub/softcatala/aspell/"
  161. version "/aspell6-ca-" version ".tar.bz2"))
  162. (hash (content-hash sha256))))
  163. (home-page "https://www.softcatala.org/pub/softcatala/aspell/"))))
  164. (define-public aspell-dict-cs
  165. (aspell-dictionary "cs" "Czech"
  166. #:version "20040614-1"
  167. #:sha256
  168. (base32
  169. "0rihj4hsw96pd9casvmpvw3r8040pfa28p1h73x4vyn20zwr3h01")))
  170. (define-public aspell-dict-de
  171. (aspell-dictionary "de" "German"
  172. #:version "20161207-7-0"
  173. #:sha256
  174. (base32
  175. "0wamclvp66xfmv5wff96v6gdlnfv4y8lx3f8wvxyzm5imwgms4n2")))
  176. (define-public aspell-dict-da
  177. (aspell-dictionary "da" "Danish"
  178. #:version "1.6.36-11-0"
  179. #:sha256
  180. (base32
  181. "1xz2haayvwlxgss9jf1x2311a1ixbk75q2vgfprjhibsmb7cpinv")))
  182. (define-public aspell-dict-el
  183. (aspell-dictionary "el" "Greek"
  184. #:version "0.08-0"
  185. #:prefix "aspell6-"
  186. #:sha256
  187. (base32
  188. "1ljcc30zg2v2h3w5h5jr5im41mw8jbsgvvhdd2cii2yzi8d0zxja")))
  189. (define-public aspell-dict-en
  190. (aspell-dictionary "en" "English"
  191. #:version "2020.12.07-0"
  192. #:sha256
  193. (base32
  194. "1cwzqkm8gr1w51rpckwlvb43sb0b5nbwy7s8ns5vi250515773sc")))
  195. (define-public aspell-dict-eo
  196. (aspell-dictionary "eo" "Esperanto"
  197. #:version "2.1.20000225a-2"
  198. #:sha256
  199. (base32
  200. "09vf0mbiicbmyb4bwb7v7lgpabnylg0wy7m3hlhl5rjdda6x3lj1")))
  201. (define-public aspell-dict-es
  202. (aspell-dictionary "es" "Spanish"
  203. #:version "1.11-2"
  204. #:sha256
  205. (base32
  206. "1k5g328ac1hdpp6fsg57d8md6i0aqcwlszp3gbmp5706wyhpydmd")))
  207. (define-public aspell-dict-fi
  208. (aspell-dictionary "fi" "Finnish"
  209. #:version "0.7-0"
  210. #:prefix "aspell6-"
  211. #:sha256
  212. (base32
  213. "07d5s08ba4dd89cmwy9icc01i6fjdykxlb9ravmhdrhi8mxz1mzq")))
  214. (define-public aspell-dict-fr
  215. (aspell-dictionary "fr" "French"
  216. #:version "0.50-3"
  217. #:prefix "aspell-"
  218. #:sha256
  219. (base32
  220. "14ffy9mn5jqqpp437kannc3559bfdrpk7r36ljkzjalxa53i0hpr")))
  221. (define-public aspell-dict-grc
  222. (aspell-dictionary "grc" "Ancient Greek"
  223. #:version "0.02-0"
  224. #:sha256
  225. (base32
  226. "1zxr8958v37v260fkqd4pg37ns5h5kyqm54hn1hg70wq5cz8h512")))
  227. (define-public aspell-dict-he
  228. (aspell-dictionary "he" "Hebrew"
  229. #:version "1.0-0"
  230. #:sha256
  231. (base32
  232. "13bhbghx5b8g0119g3wxd4n8mlf707y41vlf59irxjj0kynankfn")))
  233. (define-public aspell-dict-hi
  234. (aspell-dictionary "hi" "Hindi"
  235. #:version "0.02-0"
  236. #:prefix "aspell6-"
  237. #:sha256
  238. (base32
  239. "0drs374qz4419zx1lf2k281ydxf2750jk5ailafj1x0ncz27h1ys")))
  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. ;; The version hosted at <https://ftp.gnu.org/gnu/aspell/dict> is even
  249. ;; more out of date.
  250. (source
  251. (origin
  252. (method url-fetch)
  253. (uri (string-append "mirror://sourceforge/linguistico/"
  254. "Dizionario%20italiano%20per%20Aspell/" version "/"
  255. "aspell6-it-" version ".tar.bz2"))
  256. (hash (content-hash sha256))))
  257. (home-page
  258. "http://linguistico.sourceforge.net/pages/dizionario_italiano.html"))))
  259. (define-public aspell-dict-mi
  260. (aspell-dictionary "mi" "Maori"
  261. #:version "0.50-0"
  262. #:prefix "aspell-"
  263. #:sha256
  264. (base32
  265. "12bxplpd348yx8d2q8qvahi9dlp7qf28qmanzhziwc7np8rixvmy")))
  266. (define-public aspell-dict-nl
  267. (aspell-dictionary "nl" "Dutch"
  268. #:version "0.50-2"
  269. #:prefix "aspell-"
  270. #:sha256
  271. (base32
  272. "0ffb87yjsh211hllpc4b9khqqrblial4pzi1h9r3v465z1yhn3j4")))
  273. (define-public aspell-dict-nn
  274. (aspell-dictionary "nn" "Norwegian Nynorsk"
  275. #:version "0.50.1-1"
  276. #:prefix "aspell-"
  277. #:sha256
  278. (base32
  279. "0w2k5l5rbqpliripgqwiqixz5ghnjf7i9ggbrc4ly4vy1ia10rmc")))
  280. (define-public aspell-dict-pl
  281. (aspell-dictionary "pl" "Polish"
  282. #:version "0.51-0"
  283. #:prefix "aspell-"
  284. #:sha256
  285. (base32
  286. "1a3ccji6k5gys7l3ilr2lh5pzxgzb7ipc5vb737svl6nqgdy8757")))
  287. (define-public aspell-dict-pt-br
  288. (aspell-dictionary "pt_BR" "Brazilian Portuguese"
  289. #:version "20131030-12-0"
  290. #:sha256
  291. (base32
  292. "1xqlpk21s93c6blkdnpk7l62q9fxjvzdv2x86chl8p2x1gdrj3gb")))
  293. (define-public aspell-dict-pt-pt
  294. (aspell-dictionary "pt_PT" "Portuguese"
  295. #:version "20190329-1-0"
  296. #:sha256
  297. (base32
  298. "0ld0d0ily4jqifjfsxfv4shbicz6ymm2gk56fq9gbzra1j4qnw75")))
  299. (define-public aspell-dict-ru
  300. (aspell-dictionary "ru" "Russian"
  301. #:version "0.99f7-1"
  302. #:sha256
  303. (base32
  304. "0ip6nq43hcr7vvzbv4lwwmlwgfa60hrhsldh9xy3zg2prv6bcaaw")))
  305. (define-public aspell-dict-sl
  306. (aspell-dictionary "sl" "Slovenian"
  307. #:version "0.50-0"
  308. #:prefix "aspell-"
  309. #:sha256
  310. (base32
  311. "1l9kc5g35flq8kw9jhn2n0bjb4sipjs4qkqzgggs438kywkx2rp5")))
  312. (define-public aspell-dict-sv
  313. (aspell-dictionary "sv" "Swedish"
  314. #:version "0.51-0"
  315. #:prefix "aspell-"
  316. #:sha256
  317. (base32
  318. "02jwkjhr32kvyibnyzgx3smbnm576jwdzg3avdf6zxwckhy5fw4v")))
  319. (define-public aspell-dict-uk
  320. (aspell-dictionary "uk" "Ukrainian"
  321. #:version "1.4.0-0"
  322. #:sha256
  323. (base32
  324. "137i4njvnslab6l4s291s11xijr5jsy75lbdph32f9y183lagy9m")))
  325. (define-public aspell-dict-ro
  326. (aspell-dictionary "ro" "Romanian"
  327. #:version "3.3-2"
  328. #:prefix "aspell5-"
  329. #:sha256
  330. (base32
  331. "0gb8j9iy1acdl11jq76idgc2lbc1rq3w04favn8cyh55d1v8phsk")))
  332. ;;;
  333. ;;; Hunspell packages made from the Aspell word lists.
  334. ;;;
  335. (define* (aspell-word-list language synopsis
  336. #:optional
  337. (nick (string-map (lambda (chr)
  338. (if (char=? #\_ chr)
  339. #\-
  340. chr))
  341. (string-downcase language))))
  342. (package
  343. (name (string-append "hunspell-dict-" nick))
  344. (version "2018.04.16")
  345. (source (origin
  346. (method url-fetch)
  347. (uri (string-append
  348. "mirror://sourceforge/wordlist/SCOWL/"
  349. version "/scowl-" version ".tar.gz"))
  350. (sha256
  351. (base32
  352. "11lkrnhwrf5mvrrq45k4mads3n9aswgac8dc25ba61c75alxb5rs"))))
  353. (native-inputs
  354. `(("tar" ,tar)
  355. ("gzip" ,gzip)
  356. ("perl" ,perl)
  357. ("aspell" ,aspell)))
  358. (build-system gnu-build-system)
  359. (arguments
  360. `(#:phases
  361. (modify-phases %standard-phases
  362. (add-after 'unpack 'make-reproducible
  363. (lambda _
  364. (substitute* "speller/README_en.txt.sh"
  365. (("\\bdate\\b") ""))))
  366. (delete 'configure)
  367. (delete 'check)
  368. (replace 'build
  369. (lambda _
  370. (substitute* "speller/make-hunspell-dict"
  371. (("zip -9 .*$")
  372. "return\n"))
  373. (mkdir "speller/hunspell")
  374. ;; XXX: This actually builds all the dictionary variants.
  375. (invoke "make" "-C" "speller" "hunspell")))
  376. (replace 'install
  377. (lambda* (#:key outputs #:allow-other-keys)
  378. (let* ((out (assoc-ref %outputs "out"))
  379. (hunspell (string-append out "/share/hunspell"))
  380. (myspell (string-append out "/share/myspell"))
  381. (doc (string-append out "/share/doc/"
  382. ,name))
  383. (dot-dic ,(string-append "speller/" language ".dic")))
  384. (mkdir-p myspell)
  385. ;; Usually there's only a 'LANGUAGE.dic' file, but for the "en"
  386. ;; dictionary, there no 'en.dic'. Instead, there's a set of
  387. ;; 'en*.dic' files, hence the 'find-files' call below.
  388. (if (file-exists? dot-dic)
  389. (install-file dot-dic hunspell)
  390. (for-each (lambda (dic)
  391. (install-file dic hunspell))
  392. (find-files "speller"
  393. ,(string-append language ".*\\.dic$"))))
  394. ;; Install affix files corresponding to installed dictionaries
  395. (for-each (lambda (dic)
  396. (install-file (string-append
  397. "speller/" (basename dic ".dic") ".aff")
  398. hunspell))
  399. (find-files hunspell ".*\\.dic$"))
  400. (symlink hunspell (string-append myspell "/dicts"))
  401. (for-each (lambda (file)
  402. (install-file file doc))
  403. (find-files "."
  404. "^(Copyright|.*\\.(txt|org|md))$"))
  405. #t))))))
  406. (synopsis synopsis)
  407. (description
  408. "This package provides a dictionary for the Hunspell spell-checking
  409. library.")
  410. (home-page "http://wordlist.aspell.net/")
  411. (license (non-copyleft "file://Copyright"
  412. "Word lists come from several sources, all
  413. under permissive licensing terms. See the 'Copyright' file."))))
  414. (define-syntax define-word-list-dictionary
  415. (syntax-rules (synopsis)
  416. ((_ name language (synopsis text))
  417. (define-public name
  418. (aspell-word-list language text)))
  419. ((_ name language nick (synopsis text))
  420. (define-public name
  421. (aspell-word-list language text nick)))))
  422. (define-word-list-dictionary hunspell-dict-en
  423. "en"
  424. (synopsis "Hunspell dictionary for English"))
  425. (define-word-list-dictionary hunspell-dict-en-au
  426. "en_AU"
  427. (synopsis "Hunspell dictionary for Australian English"))
  428. (define-word-list-dictionary hunspell-dict-en-ca
  429. "en_CA"
  430. (synopsis "Hunspell dictionary for Canadian English"))
  431. (define-word-list-dictionary hunspell-dict-en-gb
  432. "en_GB-ise" "en-gb"
  433. (synopsis "Hunspell dictionary for British English, with -ise endings"))
  434. (define-word-list-dictionary hunspell-dict-en-gb-ize
  435. "en_GB-ize"
  436. (synopsis "Hunspell dictionary for British English, with -ize endings"))
  437. (define-word-list-dictionary hunspell-dict-en-us
  438. "en_US"
  439. (synopsis "Hunspell dictionary for United States English"))
  440. (define-public ispell
  441. (package
  442. (name "ispell")
  443. (version "3.4.04")
  444. (source
  445. (origin
  446. (method url-fetch)
  447. (uri (string-append "https://www.cs.hmc.edu/~geoff/tars/ispell-"
  448. version ".tar.gz"))
  449. (sha256
  450. (base32 "0gp1rwn8grkvz28wgisc2j9w9svldnaiahl3lyis118xabqddg47"))))
  451. (build-system gnu-build-system)
  452. (arguments
  453. `(#:parallel-build? #f
  454. #:tests? #f ; no tests
  455. #:phases
  456. (modify-phases %standard-phases
  457. (replace 'configure
  458. (lambda* (#:key inputs outputs #:allow-other-keys)
  459. ;; Based on local.h.linux
  460. (let* ((grep (assoc-ref inputs "grep"))
  461. (out (assoc-ref outputs "out")))
  462. (call-with-output-file "local.h"
  463. (lambda (port)
  464. (format port "#define MINIMENU~%")
  465. (format port "#define USG~%")
  466. (format port "#define HAS_RENAME~%")
  467. (format port "#define CC \"gcc\"~%")
  468. (format port "#define POUNDBANG \"#!~a\"~%" (which "sh"))
  469. (format port "#define EGREPCMD \"~a/bin/grep -Ei\"~%" grep)
  470. (format port "#define BINDIR \"~a/bin\"~%" out)
  471. (format port "#define LIBDIR \"~a/lib/ispell\"~%" out)
  472. (format port "#define MAN1DIR \"~a/share/man/man1\"~%" out)
  473. (format port "#define MAN45DIR \"~a/share/man/man5\"~%" out))))
  474. #t)))))
  475. (inputs
  476. `(("grep" ,grep)
  477. ("ncurses" ,ncurses)))
  478. (native-inputs
  479. `(("bison" ,bison)))
  480. (synopsis "Interactive spell-checking tool for Unix")
  481. (description "Ispell is an interactive spell-checking tool supporting many
  482. European languages.")
  483. (home-page "https://www.cs.hmc.edu/~geoff/ispell.html")
  484. (license bsd-3)))