2020-07-08 17:55:37 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.plantuml-server;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.plantuml-server = {
|
|
|
|
enable = mkEnableOption "PlantUML server";
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.plantuml-server;
|
2021-10-03 18:06:03 +02:00
|
|
|
defaultText = literalExpression "pkgs.plantuml-server";
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc "PlantUML server package to use";
|
2020-07-08 17:55:37 +02:00
|
|
|
};
|
|
|
|
|
2022-03-09 10:30:18 +01:00
|
|
|
packages = {
|
|
|
|
jdk = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.jdk;
|
|
|
|
defaultText = literalExpression "pkgs.jdk";
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc "JDK package to use for the server";
|
2022-03-09 10:30:18 +01:00
|
|
|
};
|
|
|
|
jetty = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.jetty;
|
|
|
|
defaultText = literalExpression "pkgs.jetty";
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc "Jetty package to use for the server";
|
2022-03-09 10:30:18 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-07-08 17:55:37 +02:00
|
|
|
user = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "plantuml";
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc "User which runs PlantUML server.";
|
2020-07-08 17:55:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "plantuml";
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc "Group which runs PlantUML server.";
|
2020-07-08 17:55:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
home = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "/var/lib/plantuml";
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc "Home directory of the PlantUML server instance.";
|
2020-07-08 17:55:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
listenHost = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "127.0.0.1";
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc "Host to listen on.";
|
2020-07-08 17:55:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
listenPort = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 8080;
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc "Port to listen on.";
|
2020-07-08 17:55:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
plantumlLimitSize = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 4096;
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc "Limits image width and height.";
|
2020-07-08 17:55:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
graphvizPackage = mkOption {
|
|
|
|
type = types.package;
|
2021-10-23 17:25:58 +02:00
|
|
|
default = pkgs.graphviz;
|
|
|
|
defaultText = literalExpression "pkgs.graphviz";
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc "Package containing the dot executable.";
|
2020-07-08 17:55:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
plantumlStats = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc "Set it to on to enable statistics report (https://plantuml.com/statistics-report).";
|
2020-07-08 17:55:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
httpAuthorization = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc "When calling the proxy endpoint, the value of HTTP_AUTHORIZATION will be used to set the HTTP Authorization header.";
|
2020-07-08 17:55:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
allowPlantumlInclude = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc "Enables !include processing which can read files from the server into diagrams. Files are read relative to the current working directory.";
|
2020-07-08 17:55:37 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
users.users.${cfg.user} = {
|
|
|
|
isSystemUser = true;
|
|
|
|
group = cfg.group;
|
|
|
|
home = cfg.home;
|
|
|
|
createHome = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
users.groups.${cfg.group} = {};
|
|
|
|
|
|
|
|
systemd.services.plantuml-server = {
|
|
|
|
description = "PlantUML server";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
path = [ cfg.home ];
|
|
|
|
environment = {
|
|
|
|
PLANTUML_LIMIT_SIZE = builtins.toString cfg.plantumlLimitSize;
|
|
|
|
GRAPHVIZ_DOT = "${cfg.graphvizPackage}/bin/dot";
|
|
|
|
PLANTUML_STATS = if cfg.plantumlStats then "on" else "off";
|
|
|
|
HTTP_AUTHORIZATION = cfg.httpAuthorization;
|
|
|
|
ALLOW_PLANTUML_INCLUDE = if cfg.allowPlantumlInclude then "true" else "false";
|
|
|
|
};
|
|
|
|
script = ''
|
2022-03-09 10:30:18 +01:00
|
|
|
${cfg.packages.jdk}/bin/java \
|
|
|
|
-jar ${cfg.packages.jetty}/start.jar \
|
2020-07-08 17:55:37 +02:00
|
|
|
--module=deploy,http,jsp \
|
2022-03-09 10:30:18 +01:00
|
|
|
jetty.home=${cfg.packages.jetty} \
|
2020-07-08 17:55:37 +02:00
|
|
|
jetty.base=${cfg.package} \
|
|
|
|
jetty.http.host=${cfg.listenHost} \
|
|
|
|
jetty.http.port=${builtins.toString cfg.listenPort}
|
|
|
|
'';
|
|
|
|
serviceConfig = {
|
|
|
|
User = cfg.user;
|
|
|
|
Group = cfg.group;
|
|
|
|
PrivateTmp = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
meta.maintainers = with lib.maintainers; [ truh ];
|
|
|
|
}
|