mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-28 01:43:15 +00:00
nixos/languagetool: add jvm options
Languagetool server can use quite a lot of memory, so it is useful to be able to pass JVM options such as `-Xmx` and others.
This commit is contained in:
parent
01383f9817
commit
0adac36fd5
@ -1,14 +1,17 @@
|
||||
{ config, lib, options, pkgs, ... }:
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.languagetool;
|
||||
settingsFormat = pkgs.formats.javaProperties {};
|
||||
in {
|
||||
settingsFormat = pkgs.formats.javaProperties { };
|
||||
in
|
||||
{
|
||||
options.services.languagetool = {
|
||||
enable = mkEnableOption "the LanguageTool server, a multilingual spelling, style, and grammar checker that helps correct or paraphrase texts";
|
||||
|
||||
package = mkPackageOption pkgs "languagetool" { };
|
||||
|
||||
port = mkOption {
|
||||
type = types.port;
|
||||
default = 8081;
|
||||
@ -31,7 +34,7 @@ in {
|
||||
'';
|
||||
};
|
||||
|
||||
settings = lib.mkOption {
|
||||
settings = mkOption {
|
||||
type = types.submodule {
|
||||
freeformType = settingsFormat.type;
|
||||
|
||||
@ -49,11 +52,25 @@ in {
|
||||
for supported settings.
|
||||
'';
|
||||
};
|
||||
|
||||
jrePackage = mkPackageOption pkgs "jre" { };
|
||||
|
||||
jvmOptions = mkOption {
|
||||
description = ''
|
||||
Extra command line options for the JVM running languagetool.
|
||||
More information can be found here: https://docs.oracle.com/en/java/javase/19/docs/specs/man/java.html#standard-options-for-java
|
||||
'';
|
||||
default = [ ];
|
||||
type = types.listOf types.str;
|
||||
example = [
|
||||
"-Xmx512m"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
systemd.services.languagetool = {
|
||||
systemd.services.languagetool = {
|
||||
description = "LanguageTool HTTP server";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
@ -66,12 +83,15 @@ in {
|
||||
SystemCallFilter = [ "@system-service" "~ @privileged" ];
|
||||
ProtectHome = "yes";
|
||||
ExecStart = ''
|
||||
${pkgs.languagetool}/bin/languagetool-http-server \
|
||||
--port ${toString cfg.port} \
|
||||
${optionalString cfg.public "--public"} \
|
||||
${optionalString (cfg.allowOrigin != null) "--allow-origin ${cfg.allowOrigin}"} \
|
||||
"--config" ${settingsFormat.generate "languagetool.conf" cfg.settings}
|
||||
'';
|
||||
${cfg.jrePackage}/bin/java \
|
||||
-cp ${cfg.package}/share/languagetool-server.jar \
|
||||
${toString cfg.jvmOptions} \
|
||||
org.languagetool.server.HTTPServer \
|
||||
--port ${toString cfg.port} \
|
||||
${optionalString cfg.public "--public"} \
|
||||
${optionalString (cfg.allowOrigin != null) "--allow-origin ${cfg.allowOrigin}"} \
|
||||
"--config" ${settingsFormat.generate "languagetool.conf" cfg.settings}
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user