Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
269c26da70
wip: Add medical/American hunspell dict 2026-10-31 10:53:08 -05:00
3 changed files with 83 additions and 3 deletions

View file

@ -1,4 +1,10 @@
{ pkgs, custom-pkgs, ... }: {
{
pkgs,
lib,
custom-pkgs,
...
}:
{
imports = [
./../programs/firefox.nix
@ -31,6 +37,7 @@
woodpecker-cli
(texlive.combine { inherit (texlive) scheme-basic latex-bin latexmk; })
custom-pkgs.ark
custom-pkgs.hunspell-en-med
custom-pkgs.jlfmt
custom-pkgs.runic
];
@ -48,5 +55,21 @@
'';
};
};
services = { syncthing.enable = true; };
services = {
syncthing.enable = true;
};
# Symlink the merged en_MED Hunspell dictionary into the user dictionary
# directory that Qt/Sonnet (and macOS native spellcheck) scan at startup.
home.file = lib.mkIf pkgs.stdenv.isDarwin {
"Library/Spelling/en_MED.dic".source = "${custom-pkgs.hunspell-en-med}/share/hunspell/en_MED.dic";
"Library/Spelling/en_MED.aff".source = "${custom-pkgs.hunspell-en-med}/share/hunspell/en_MED.aff";
};
# On Linux, Qt/Sonnet resolves QStandardPaths::GenericDataLocation + "/hunspell"
# which maps to ~/.local/share/hunspell (managed via xdg.dataFile).
xdg.dataFile = lib.mkIf pkgs.stdenv.isLinux {
"hunspell/en_MED.dic".source = "${custom-pkgs.hunspell-en-med}/share/hunspell/en_MED.dic";
"hunspell/en_MED.aff".source = "${custom-pkgs.hunspell-en-med}/share/hunspell/en_MED.aff";
};
}

View file

@ -1,6 +1,8 @@
{ pkgs, ... }:
with pkgs; {
with pkgs;
{
ark = callPackage ./ark.nix { };
hunspell-en-med = callPackage ./hunspell-en-med.nix { };
jlfmt = callPackage ./jlfmt.nix { };
runic = callPackage ./runic.nix { };
sc4pac = callPackage ./sc4pac.nix { };

55
pkgs/hunspell-en-med.nix Normal file
View file

@ -0,0 +1,55 @@
{ pkgs, lib }:
let
# Hunspell dictionary of English medical terms by glutanimate.
# Merges OpenMedSpel (R. Robinson) and MTH-Med-Spel-Chek (Rajasekharan N.),
# covering ~90,000 terms (anatomy, pharmacology, DSM-IV, ICD-9, etc.).
# Note: word list is current to April 2014; GPL-3.0 licensed.
# Source: https://github.com/glutanimate/hunspell-en-med-glut
medDic = pkgs.fetchurl {
url = "https://raw.githubusercontent.com/glutanimate/hunspell-en-med-glut/master/en_med_glut.dic";
# Run `nix build` once with this placeholder to get the real hash from the
# error message, then replace it here.
hash = "sha256-voNMOdaB3QED0Lut3KujWXhr0Sa+sdDAi27ZMoVJDBs=";
};
in
pkgs.stdenv.mkDerivation {
pname = "hunspell-en-med";
# Date of last upstream commit to the dictionary file
version = "2017-01-04";
dontUnpack = true;
installPhase = ''
runHook preInstall
mkdir -p $out/share/hunspell
# Strip the word-count header from both .dic files, concatenate,
# de-duplicate, then prepend the new count to form a valid .dic file.
{
tail -n +2 "${pkgs.hunspellDicts.en_US}/share/hunspell/en_US.dic"
tail -n +2 ${medDic}
} | sort -u > words.txt
count=$(wc -l < words.txt)
{ printf '%s\n' "$count"; cat words.txt; } > $out/share/hunspell/en_MED.dic
# Reuse en_US affix rules; the medical word list carries no morphology.
cp "${pkgs.hunspellDicts.en_US}/share/hunspell/en_US.aff" $out/share/hunspell/en_MED.aff
runHook postInstall
'';
meta = {
description = "Merged US English + medical terms Hunspell dictionary (en_MED)";
longDescription = ''
Combines the standard en_US Hunspell dictionary with the glutanimate
medical terms word list (hunspell-en-med-glut), giving a single
en_MED dictionary that covers everyday English and ~90,000 medical terms.
'';
homepage = "https://github.com/glutanimate/hunspell-en-med-glut";
license = lib.licenses.gpl3;
platforms = lib.platforms.all;
};
}