Services: Add LanguageTool as a hosted service
This commit is contained in:
parent
fc59fc97a4
commit
0b0f3548b5
|
@ -234,11 +234,11 @@
|
||||||
"nix-secrets": {
|
"nix-secrets": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1721656822,
|
"lastModified": 1722196383,
|
||||||
"narHash": "sha256-85jL6CvmxPloZDL313Eezu8mcEeGM+YzonlYyshz3w0=",
|
"narHash": "sha256-2tU2b8YFpMtHe/YKFS8SmQiJCqnZ12hvc8KKspBBXRY=",
|
||||||
"ref": "refs/heads/main",
|
"ref": "refs/heads/main",
|
||||||
"rev": "5f2de4bcc3be600a26db59334186537a23c4693b",
|
"rev": "39cb0b58584e4763879310c779f75e30dd0b778a",
|
||||||
"revCount": 54,
|
"revCount": 55,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "file:./nix-secrets"
|
"url": "file:./nix-secrets"
|
||||||
},
|
},
|
||||||
|
|
|
@ -181,6 +181,13 @@ in
|
||||||
token = config.secrets.services.forgejo.runner-token;
|
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;
|
msmtp.enable = true;
|
||||||
nginx = {
|
nginx = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
66
modules/services/languagetool.nix
Normal file
66
modules/services/languagetool.nix
Normal 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
|
Loading…
Reference in a new issue