lol
1{lib, stdenv, fetchurl, aspell, which}:
2
3with lib;
4
5/* HOWTO:
6
7 * Add some of these to your profile or systemPackages.
8
9 ~~~~
10 environment.systemPackages = [
11 aspell
12 aspellDicts.en
13 aspellDicts.en-computers
14 aspellDicts.en-science
15 ];
16 ~~~~
17
18 * Rebuild and switch to the new profile.
19 * Add something like
20
21 ~~~~
22 master en_US
23 extra-dicts en-computers.rws
24 add-extra-dicts en_US-science.rws
25 ~~~~
26
27 to `/etc/aspell.conf` or `~/.aspell.conf`.
28 * Check that `aspell -a` starts without errors.
29 * (optional) Check your config with `aspell dump config | grep -vE '^(#|$)'`.
30 * Enjoy.
31
32*/
33
34let
35
36 /* Function to compile an Aspell dictionary. Fortunately, they all
37 build in the exact same way. */
38 buildDict =
39 {shortName, fullName, ...}@args:
40
41 stdenv.mkDerivation ({
42 name = "aspell-dict-${shortName}";
43
44 buildInputs = [aspell which];
45
46 dontAddPrefix = true;
47
48 preBuild = "makeFlagsArray=(dictdir=$out/lib/aspell datadir=$out/lib/aspell)";
49
50 meta = {
51 description = "Aspell dictionary for ${fullName}";
52 platforms = stdenv.lib.platforms.all;
53 } // (args.meta or {});
54 } // removeAttrs args [ "meta" ]);
55
56 /* Function to compile txt dict files into Aspell dictionaries. */
57 buildTxtDict =
58 {langInputs ? [], ...}@args:
59 buildDict ({
60 propagatedUserEnvPackages = langInputs;
61
62 preBuild = ''
63 # Aspell can't handle multiple data-dirs
64 # Copy everything we might possibly need
65 ${concatMapStringsSep "\n" (p: ''
66 cp -a ${p}/lib/aspell/* .
67 '') ([ aspell ] ++ langInputs)}
68 export ASPELL_CONF="data-dir $(pwd)"
69
70 aspell-create() {
71 target=$1
72 shift
73 echo building $target
74 aspell create "$@" master ./$target.rws
75 }
76
77 words-only() {
78 awk -F'\t' '{print $1}' | sort | uniq
79 }
80
81 # drop comments
82 aspell-affix() {
83 words-only \
84 | grep -v '#' \
85 | aspell-create "$@"
86 }
87
88 # Hack: drop comments and words with affixes
89 aspell-plain() {
90 words-only \
91 | grep -v '#' \
92 | grep -v '/' \
93 | aspell-create "$@"
94 }
95
96 aspell-install() {
97 install -d $out/lib/aspell
98 for a in "$@"; do
99 echo installing $a
100 install -t $out/lib/aspell $a.rws
101 done
102 }
103 '';
104
105 phases = [ "preBuild" "buildPhase" "installPhase" ];
106 } // args);
107
108in rec {
109
110 ### Languages
111
112 ca = buildDict rec {
113 shortName = "ca-2.1.5-1";
114 fullName = "Catalan";
115 src = fetchurl {
116 url = "mirror://gnu/aspell/dict/ca/aspell6-${shortName}.tar.bz2";
117 sha256 = "1fb5y5kgvk25nlsfvc8cai978hg66x3pbp9py56pldc7vxzf9npb";
118 };
119 };
120
121 cs = buildDict rec {
122 shortName = "cs-20040614-1";
123 fullName = "Czech";
124 src = fetchurl {
125 url = "mirror://gnu/aspell/dict/cs/aspell6-${shortName}.tar.bz2";
126 sha256 = "0rihj4hsw96pd9casvmpvw3r8040pfa28p1h73x4vyn20zwr3h01";
127 };
128 };
129
130 da = buildDict rec {
131 shortName = "da-1.4.42-1";
132 fullName = "Danish";
133 src = fetchurl {
134 url = "mirror://gnu/aspell/dict/da/aspell5-${shortName}.tar.bz2";
135 sha256 = "1hfkmiyhgrx5lgrb2mffjbdn1hivrm73wcg7x0iid74p2yb0fjpp";
136 };
137 };
138
139 de = buildDict rec {
140 shortName = "de-20030222-1";
141 fullName = "German";
142 src = fetchurl {
143 url = "mirror://gnu/aspell/dict/de/aspell6-${shortName}.tar.bz2";
144 sha256 = "01p92qj66cqb346gk7hjfynaap5sbcn85xz07kjfdq623ghr8v5s";
145 };
146 };
147
148 en = buildDict rec {
149 shortName = "en-2016.06.26-0";
150 fullName = "English";
151 src = fetchurl {
152 url = "mirror://gnu/aspell/dict/en/aspell6-${shortName}.tar.bz2";
153 sha256 = "1clzsfq2cbgp6wvfr2qwfsd2nziipml5m5vqm45r748wczlxihv1";
154 };
155 };
156
157 es = buildDict rec {
158 shortName = "es-1.11-2";
159 fullName = "Spanish";
160 src = fetchurl {
161 url = "mirror://gnu/aspell/dict/es/aspell6-${shortName}.tar.bz2";
162 sha256 = "1k5g328ac1hdpp6fsg57d8md6i0aqcwlszp3gbmp5706wyhpydmd";
163 };
164 };
165
166 eo = buildDict rec {
167 shortName = "eo-2.1.20000225a-2";
168 fullName = "Esperanto";
169 src = fetchurl {
170 url = "mirror://gnu/aspell/dict/eo/aspell6-${shortName}.tar.bz2";
171 sha256 = "09vf0mbiicbmyb4bwb7v7lgpabnylg0wy7m3hlhl5rjdda6x3lj1";
172 };
173 };
174
175 fr = buildDict rec {
176 shortName = "fr-0.50-3";
177 fullName = "French";
178 src = fetchurl {
179 url = "mirror://gnu/aspell/dict/fr/aspell-${shortName}.tar.bz2";
180 sha256 = "14ffy9mn5jqqpp437kannc3559bfdrpk7r36ljkzjalxa53i0hpr";
181 };
182 };
183
184 it = buildDict rec {
185 shortName = "it-2.2_20050523-0";
186 fullName = "Italian";
187 src = fetchurl {
188 url = "mirror://gnu/aspell/dict/it/aspell6-${shortName}.tar.bz2";
189 sha256 = "1gdf7bc1a0kmxsmphdqq8pl01h667mjsj6hihy6kqy14k5qdq69v";
190 };
191 };
192
193 la = buildDict rec {
194 shortName = "la-20020503-0";
195 fullName = "Latin";
196 src = fetchurl {
197 url = "mirror://gnu/aspell/dict/la/aspell6-${shortName}.tar.bz2";
198 sha256 = "1199inwi16dznzl087v4skn66fl7h555hi2palx6s1f3s54b11nl";
199 };
200 };
201
202 nb = buildDict rec {
203 shortName = "nb-0.50.1-0";
204 fullName = "Norwegian Bokmal";
205 src = fetchurl {
206 url = "mirror://gnu/aspell/dict/nb/aspell-${shortName}.tar.bz2";
207 sha256 = "12i2bmgdnlkzfinb20j2a0j4a20q91a9j8qpq5vgabbvc65nwx77";
208 };
209 };
210
211 nl = buildDict rec {
212 shortName = "nl-0.50-2";
213 fullName = "Dutch";
214 src = fetchurl {
215 url = "mirror://gnu/aspell/dict/nl/aspell-${shortName}.tar.bz2";
216 sha256 = "0ffb87yjsh211hllpc4b9khqqrblial4pzi1h9r3v465z1yhn3j4";
217 };
218 # Emacs expects a language called "nederlands".
219 postInstall = ''
220 echo "add nl.rws" > $out/lib/aspell/nederlands.multi
221 '';
222 };
223
224 nn = buildDict rec {
225 shortName = "nn-0.50.1-1";
226 fullName = "Norwegian Nynorsk";
227 src = fetchurl {
228 url = "mirror://gnu/aspell/dict/nn/aspell-${shortName}.tar.bz2";
229 sha256 = "0w2k5l5rbqpliripgqwiqixz5ghnjf7i9ggbrc4ly4vy1ia10rmc";
230 };
231 };
232
233 pl = buildDict rec {
234 shortName = "pl-6.0_20061121-0";
235 fullName = "Polish";
236 src = fetchurl {
237 url = "mirror://gnu/aspell/dict/pl/aspell6-${shortName}.tar.bz2";
238 sha256 = "0kap4kh6bqbb22ypja1m5z3krc06vv4n0hakiiqmv20anzy42xq1";
239 };
240 };
241
242 pt_BR = buildDict rec {
243 shortName = "pt_BR-20090702-0";
244 fullName = "Brazilian Portuguese";
245 src = fetchurl {
246 url = "mirror://gnu/aspell/dict/pt_BR/aspell6-${shortName}.tar.bz2";
247 sha256 = "1y09lx9zf2rnp55r16b2vgj953l3538z1vaqgflg9mdvm555bz3p";
248 };
249 };
250
251 pt_PT = buildDict rec {
252 shortName = "pt_PT-20070510-0";
253 fullName = "Portuguese";
254 src = fetchurl {
255 url = "mirror://gnu/aspell/dict/pt_PT/aspell6-${shortName}.tar.bz2";
256 sha256 = "1mnr994cwlag6shy8865ky99lymysiln07mbldcncahg90dagdxq";
257 };
258 };
259
260 ro = buildDict rec {
261 shortName = "ro-3.3-2";
262 fullName = "Romanian";
263 src = fetchurl {
264 url = "mirror://gnu/aspell/dict/ro/aspell5-${shortName}.tar.bz2";
265 sha256 = "0gb8j9iy1acdl11jq76idgc2lbc1rq3w04favn8cyh55d1v8phsk";
266 };
267 };
268
269 ru = buildDict rec {
270 shortName = "ru-0.99f7-1";
271 fullName = "Russian";
272 src = fetchurl {
273 url = "mirror://gnu/aspell/dict/ru/aspell6-${shortName}.tar.bz2";
274 sha256 = "0ip6nq43hcr7vvzbv4lwwmlwgfa60hrhsldh9xy3zg2prv6bcaaw";
275 };
276 };
277
278 sv = buildDict rec {
279 shortName = "sv-0.51-0";
280 fullName = "Swedish";
281 src = fetchurl {
282 url = "mirror://gnu/aspell/dict/sv/aspell-${shortName}.tar.bz2";
283 sha256 = "02jwkjhr32kvyibnyzgx3smbnm576jwdzg3avdf6zxwckhy5fw4v";
284 };
285 };
286
287 sk = buildDict rec {
288 shortName = "sk-2.01-2";
289 fullName = "Slovak";
290 src = fetchurl {
291 url = "mirror://gnu/aspell/dict/sk/aspell6-${shortName}.tar.bz2";
292 sha256 = "19k0m1v5pcf7xr4lxgjkzqkdlks8nyb13bvi1n7521f3i4lhma66";
293 };
294 };
295
296 tr = buildDict rec {
297 shortName = "tr-0.50-0";
298 fullName = "Turkish";
299 src = fetchurl {
300 url = "mirror://gnu/aspell/dict/tr/aspell-${shortName}.tar.bz2";
301 sha256 = "0jpvpm96ga7s7rmsm6rbyrrr22b2dicxv2hy7ysv5y7bbq757ihb";
302 };
303 };
304
305 uk = buildDict rec {
306 shortName = "uk-1.4.0-0";
307 fullName = "Ukrainian";
308 src = fetchurl {
309 url = "mirror://gnu/aspell/dict/uk/aspell6-${shortName}.tar.bz2";
310 sha256 = "137i4njvnslab6l4s291s11xijr5jsy75lbdph32f9y183lagy9m";
311 };
312 };
313
314 ### Jargons
315
316 en-computers = buildTxtDict rec {
317 shortName = "en-computers";
318 fullName = "English Computer Jargon";
319
320 src = fetchurl {
321 url = https://mrsatterly.com/computer.dic;
322 sha256 = "1vzk7cdvcm9r1c6mgxpabrdcpvghdv9mjmnf6iq5wllcif5nsw2b";
323 };
324
325 langInputs = [ en ];
326
327 buildPhase = "cat $src | aspell-affix en-computers --dont-validate-words --lang=en";
328 installPhase = "aspell-install en-computers";
329
330 meta = {
331 homepage = https://mrsatterly.com/spelling.html;
332 };
333 };
334
335 en-science = buildTxtDict rec {
336 shortName = "en-science";
337 fullName = "English Scientific Jargon";
338
339 src1 = fetchurl {
340 url = http://jpetrie.net/wp-content/uploads/custom_scientific_US.txt;
341 sha256 = "1psqm094zl4prk2f8h18jv0d471hxykzd1zdnrlx7gzrzy6pz5r3";
342 };
343
344 src2 = fetchurl {
345 url = http://jpetrie.net/wp-content/uploads/custom_scientific_UK.txt;
346 sha256 = "17ss1sdr3k70zbyx2z9xf74345slrp41gbkpih8axrmg4x92fgm1";
347 };
348
349 langInputs = [ en ];
350
351 buildPhase = ''
352 cat $src1 | aspell-plain en_US-science --dont-validate-words --lang=en
353 cat $src2 | aspell-plain en_GB-science --dont-validate-words --lang=en
354 '';
355 installPhase = "aspell-install en_US-science en_GB-science";
356
357 meta = {
358 homepage = http://www.jpetrie.net/scientific-word-list-for-spell-checkersspelling-dictionaries/;
359 };
360
361 };
362
363}