-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aspellDicts: add more dictionaries and some documentation #34798
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,113 @@ | ||
{stdenv, fetchurl, aspell, which}: | ||
{lib, stdenv, fetchurl, aspell, which}: | ||
|
||
with lib; | ||
|
||
/* HOWTO: | ||
|
||
* Add some of these to your profile or systemPackages. | ||
|
||
~~~~ | ||
environment.systemPackages = [ | ||
aspell | ||
aspellDicts.en | ||
aspellDicts.en-computers | ||
aspellDicts.en-science | ||
]; | ||
~~~~ | ||
|
||
* Rebuild and switch to the new profile. | ||
* Add something like | ||
|
||
~~~~ | ||
master en_US | ||
extra-dicts en-computers.rws | ||
add-extra-dicts en_US-science.rws | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are these needed? Should it not detect them? |
||
~~~~ | ||
|
||
to `/etc/aspell.conf` or `~/.aspell.conf`. | ||
* Check that `aspell -a` starts without errors. | ||
* (optional) Check your config with `aspell dump config | grep -vE '^(#|$)'`. | ||
* Enjoy. | ||
|
||
*/ | ||
|
||
let | ||
|
||
/* Function to compile an Aspell dictionary. Fortunately, they all | ||
build in the exact same way. */ | ||
buildDict = | ||
{shortName, fullName, src, postInstall ? ""}: | ||
{shortName, fullName, ...}@args: | ||
|
||
stdenv.mkDerivation { | ||
stdenv.mkDerivation ({ | ||
name = "aspell-dict-${shortName}"; | ||
|
||
inherit src; | ||
|
||
buildInputs = [aspell which]; | ||
|
||
dontAddPrefix = true; | ||
|
||
preBuild = "makeFlagsArray=(dictdir=$out/lib/aspell datadir=$out/lib/aspell)"; | ||
|
||
inherit postInstall; | ||
|
||
meta = { | ||
description = "Aspell dictionary for ${fullName}"; | ||
platforms = stdenv.lib.platforms.all; | ||
}; | ||
}; | ||
|
||
in { | ||
} // (args.meta or {}); | ||
} // removeAttrs args [ "meta" ]); | ||
|
||
/* Function to compile txt dict files into Aspell dictionaries. */ | ||
buildTxtDict = | ||
{langInputs ? [], ...}@args: | ||
buildDict ({ | ||
propagatedUserEnvPackages = langInputs; | ||
|
||
preBuild = '' | ||
# Aspell can't handle multiple data-dirs | ||
# Copy everything we might possibly need | ||
${concatMapStringsSep "\n" (p: '' | ||
cp -a ${p}/lib/aspell/* . | ||
'') ([ aspell ] ++ langInputs)} | ||
export ASPELL_CONF="data-dir $(pwd)" | ||
|
||
aspell-create() { | ||
target=$1 | ||
shift | ||
echo building $target | ||
aspell create "$@" master ./$target.rws | ||
} | ||
|
||
words-only() { | ||
awk -F'\t' '{print $1}' | sort | uniq | ||
} | ||
|
||
# drop comments | ||
aspell-affix() { | ||
words-only \ | ||
| grep -v '#' \ | ||
| aspell-create "$@" | ||
} | ||
|
||
# Hack: drop comments and words with affixes | ||
aspell-plain() { | ||
words-only \ | ||
| grep -v '#' \ | ||
| grep -v '/' \ | ||
| aspell-create "$@" | ||
} | ||
|
||
aspell-install() { | ||
install -d $out/lib/aspell | ||
for a in "$@"; do | ||
echo installing $a | ||
install -t $out/lib/aspell $a.rws | ||
done | ||
} | ||
''; | ||
|
||
phases = [ "preBuild" "buildPhase" "installPhase" ]; | ||
} // args); | ||
|
||
in rec { | ||
|
||
### Languages | ||
|
||
ca = buildDict { | ||
shortName = "ca-2.1.5-1"; | ||
|
@@ -230,4 +311,53 @@ in { | |
}; | ||
}; | ||
|
||
### Jargons | ||
|
||
en-computers = buildTxtDict rec { | ||
shortName = "en-computers"; | ||
fullName = "English Computer Jargon"; | ||
|
||
src = fetchurl { | ||
url = https://mrsatterly.com/computer.dic; | ||
sha256 = "1vzk7cdvcm9r1c6mgxpabrdcpvghdv9mjmnf6iq5wllcif5nsw2b"; | ||
}; | ||
|
||
langInputs = [ en ]; | ||
|
||
buildPhase = "cat $src | aspell-affix en-computers --dont-validate-words --lang=en"; | ||
installPhase = "aspell-install en-computers"; | ||
|
||
meta = { | ||
homepage = https://mrsatterly.com/spelling.html; | ||
}; | ||
}; | ||
|
||
en-science = buildTxtDict rec { | ||
shortName = "en-science"; | ||
fullName = "English Scientific Jargon"; | ||
|
||
src1 = fetchurl { | ||
url = http://jpetrie.net/wp-content/uploads/custom_scientific_US.txt; | ||
sha256 = "1psqm094zl4prk2f8h18jv0d471hxykzd1zdnrlx7gzrzy6pz5r3"; | ||
}; | ||
|
||
src2 = fetchurl { | ||
url = http://jpetrie.net/wp-content/uploads/custom_scientific_UK.txt; | ||
sha256 = "17ss1sdr3k70zbyx2z9xf74345slrp41gbkpih8axrmg4x92fgm1"; | ||
}; | ||
|
||
langInputs = [ en ]; | ||
|
||
buildPhase = '' | ||
cat $src1 | aspell-plain en_US-science --dont-validate-words --lang=en | ||
cat $src2 | aspell-plain en_GB-science --dont-validate-words --lang=en | ||
''; | ||
installPhase = "aspell-install en_US-science en_GB-science"; | ||
|
||
meta = { | ||
homepage = http://www.jpetrie.net/scientific-word-list-for-spell-checkersspelling-dictionaries/; | ||
}; | ||
|
||
}; | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only considers the method where dicts are installed separate from aspell, and not
aspellWithDicts
. Perhaps there is a better place for this comment? Otherwise, it's good to have the explanation!