1
0
Fork 0

Apps: re-enable LanguageTool

This commit is contained in:
Aires 2024-09-28 13:42:40 -04:00
parent 9e37678202
commit f0495113cf
4 changed files with 64 additions and 3 deletions

View file

@ -25,7 +25,13 @@ in
office.enable = true;
recording.enable = true;
social.enable = true;
writing.enable = true;
writing = {
enable = true;
languagetool = {
enable = true;
ngrams.enable = true;
};
};
};
# Enable Secure Boot support.

View file

@ -10,7 +10,17 @@ let
in
{
options = {
aux.system.apps.writing.enable = lib.mkEnableOption "Enables writing and editing tools";
aux.system.apps.writing = {
enable = lib.mkEnableOption "Enables writing and editing tools";
languagetool = {
enable = lib.mkEnableOption (lib.mdDoc "Enables local Language Tool server.");
# WARNING: Ngrams package requires a lot of RAM
ngrams.enable = lib.mkEnableOption (
lib.mdDoc "Enables ngrams for improved grammar detection (warning: results in an 8GB+ download)."
);
};
};
};
config = lib.mkIf cfg.enable {
@ -21,5 +31,17 @@ in
haskellPackages.pandoc-crossref
texliveSmall
];
# Spelling and grammer checking: hosted on localhost:8081
services.languagetool = lib.mkIf cfg.languagetool.enable {
enable = true;
port = 8090;
public = false;
allowOrigin = "*";
# Enable Ngrams
settings.languageModel = lib.mkIf cfg.languagetool.ngrams.enable "${
(pkgs.callPackage ../../packages/languagetool-ngrams.nix { inherit pkgs lib; })
}/ngrams";
};
};
}

View file

@ -90,7 +90,7 @@ in
theme = "gentoo";
};
shellAliases = {
nos = lib.mkIf config.aux.system.nixos-upgrade-script.enable "nixos-upgrade-script";
nos = "nixos-upgrade-script";
z = "zellij";
update = "upgrade";
upgrade = "nh os boot --update --ask";

View file

@ -0,0 +1,33 @@
# For a packaging example, see https://github.com/Janik-Haag/nix-languagetool-ngram/blob/main/ngram-template.nix
{
pkgs,
lib,
fetchzip,
}:
pkgs.stdenv.mkDerivation rec {
pname = "languagetool-ngram-en";
version = "20150817";
language = "en";
src = fetchzip {
url = "https://languagetool.org/download/ngram-data/ngrams-${language}-${version}.zip";
sha256 = "10e548731d9f58189fc36a553f7f685703be30da0d9bb42d1f7b5bf5f8bb232c";
};
dontBuild = true;
dontConfigure = true;
dontFixup = true;
installPhase = ''
mkdir -p $out/share/languagetool/ngrams
ln -s $src $out/share/languagetool/ngrams/${language}
'';
meta = with lib; {
homepage = "https://dev.languagetool.org/finding-errors-using-n-gram-data.html";
description = "LanguageTool can make use of large n-gram data sets to detect errors with words that are often confused, like their and there.";
platforms = platforms.linux;
license = licenses.cc-by-sa-40;
};
}