1
0
Fork 0

Services: Add LanguageTool as a hosted service

This commit is contained in:
Aires 2024-07-28 15:56:28 -04:00
parent fc59fc97a4
commit 0b0f3548b5
4 changed files with 78 additions and 5 deletions

View file

@ -234,11 +234,11 @@
"nix-secrets": {
"flake": false,
"locked": {
"lastModified": 1721656822,
"narHash": "sha256-85jL6CvmxPloZDL313Eezu8mcEeGM+YzonlYyshz3w0=",
"lastModified": 1722196383,
"narHash": "sha256-2tU2b8YFpMtHe/YKFS8SmQiJCqnZ12hvc8KKspBBXRY=",
"ref": "refs/heads/main",
"rev": "5f2de4bcc3be600a26db59334186537a23c4693b",
"revCount": 54,
"rev": "39cb0b58584e4763879310c779f75e30dd0b778a",
"revCount": 55,
"type": "git",
"url": "file:./nix-secrets"
},

View file

@ -181,6 +181,13 @@ in
token = config.secrets.services.forgejo.runner-token;
};
};
languagetool = {
enable = true;
ngrams.enable = true;
domain = config.secrets.networking.primaryDomain;
password = config.secrets.services.languagetool.password;
url = config.secrets.services.languagetool.url;
};
msmtp.enable = true;
nginx = {
enable = true;

View file

@ -0,0 +1,66 @@
{
pkgs,
config,
lib,
...
}:
let
cfg = config.aux.system.services.languagetool;
in
{
options = {
aux.system.services.languagetool = {
enable = lib.mkEnableOption (lib.mdDoc "Enables LanguageTool server.");
ngrams.enable = lib.mkEnableOption (
lib.mdDoc "Enables n-gram data set. See https://dev.languagetool.org/finding-errors-using-n-gram-data.html"
);
domain = lib.mkOption {
default = "";
type = lib.types.str;
description = "The root domain that LanguageTool will be hosted on.";
example = "example.com";
};
password = lib.mkOption {
default = "";
type = lib.types.str;
description = "The password to use for basic authentication for LanguageTool.";
example = "MySuperSecurePassword123";
};
url = lib.mkOption {
default = "";
type = lib.types.str;
description = "The complete URL where LanguageTool is hosted.";
example = "https://languagetool.example.com";
};
};
};
config = lib.mkIf cfg.enable {
services = {
languagetool = lib.mkIf cfg.enable {
enable = true;
port = 8090;
public = true;
allowOrigin = "*";
# Enable Ngrams
settings.languageModel = lib.mkIf cfg.ngrams.enable "${
(pkgs.callPackage ../../packages/languagetool-ngrams.nix { inherit pkgs lib; })
}/ngrams";
};
# Create Nginx virtualhost
nginx.virtualHosts."${cfg.url}" = {
useACMEHost = cfg.domain;
forceSSL = true;
basicAuth = {
ltuser = cfg.password;
};
locations."/" = {
proxyPass = "http://127.0.0.1:8090";
extraConfig = "proxy_ssl_server_name on;";
};
};
};
systemd.services.nginx.wants = [ config.systemd.services.languagetool.name ];
};
}

@ -1 +1 @@
Subproject commit 5f2de4bcc3be600a26db59334186537a23c4693b
Subproject commit 39cb0b58584e4763879310c779f75e30dd0b778a