1 { config, lib, pkgs, ... }:
14 cfg = config.services.plantuml-server;
20 (mkRemovedOptionModule [ "services" "plantuml-server" "allowPlantumlInclude" ] "This option has been removed from PlantUML.")
24 services.plantuml-server = {
25 enable = mkEnableOption "PlantUML server";
27 package = mkPackageOption pkgs "plantuml-server" { };
30 jdk = mkPackageOption pkgs "jdk" { };
31 jetty = mkPackageOption pkgs "jetty" {
32 default = [ "jetty_11" ];
34 At the time of writing (v1.2023.12), PlantUML Server does not support
35 Jetty versions higher than 12.x.
37 Jetty 12.x has introduced major breaking changes, see
38 <https://github.com/jetty/jetty.project/releases/tag/jetty-12.0.0> and
39 <https://eclipse.dev/jetty/documentation/jetty-12/programming-guide/index.html#pg-migration-11-to-12>
47 description = "User which runs PlantUML server.";
53 description = "Group which runs PlantUML server.";
58 default = "/var/lib/plantuml";
59 description = "Home directory of the PlantUML server instance.";
62 listenHost = mkOption {
64 default = "127.0.0.1";
65 description = "Host to listen on.";
68 listenPort = mkOption {
71 description = "Port to listen on.";
74 plantumlLimitSize = mkOption {
77 description = "Limits image width and height.";
80 graphvizPackage = mkPackageOption pkgs "graphviz" { };
82 plantumlStats = mkOption {
85 description = "Set it to on to enable statistics report (https://plantuml.com/statistics-report).";
88 httpAuthorization = mkOption {
89 type = types.nullOr types.str;
91 description = "When calling the proxy endpoint, the value of HTTP_AUTHORIZATION will be used to set the HTTP Authorization header.";
96 config = mkIf cfg.enable {
97 systemd.services.plantuml-server = {
98 description = "PlantUML server";
99 wantedBy = [ "multi-user.target" ];
103 PLANTUML_LIMIT_SIZE = builtins.toString cfg.plantumlLimitSize;
104 GRAPHVIZ_DOT = "${cfg.graphvizPackage}/bin/dot";
105 PLANTUML_STATS = if cfg.plantumlStats then "on" else "off";
106 HTTP_AUTHORIZATION = cfg.httpAuthorization;
109 ${cfg.packages.jdk}/bin/java \
110 -jar ${cfg.packages.jetty}/start.jar \
111 --module=deploy,http,jsp \
112 jetty.home=${cfg.packages.jetty} \
113 jetty.base=${cfg.package} \
114 jetty.http.host=${cfg.listenHost} \
115 jetty.http.port=${builtins.toString cfg.listenPort}
121 StateDirectory = mkIf (cfg.home == "/var/lib/plantuml") "plantuml";
122 StateDirectoryMode = mkIf (cfg.home == "/var/lib/plantuml") "0750";
125 AmbientCapabilities = [ "" ];
126 CapabilityBoundingSet = [ "" ];
128 LockPersonality = true;
129 NoNewPrivileges = true;
130 PrivateDevices = true;
131 PrivateNetwork = false;
135 ProtectControlGroups = true;
137 ProtectHostname = true;
138 ProtectKernelLogs = true;
139 ProtectKernelModules = true;
140 ProtectKernelTunables = true;
141 ProtectSystem = "strict";
142 RestrictAddressFamilies = [ "AF_UNIX" "AF_INET" "AF_INET6" ];
143 RestrictNamespaces = true;
144 RestrictRealtime = true;
145 RestrictSUIDSGID = true;
146 SystemCallArchitectures = "native";
147 SystemCallFilter = [ "@system-service" ];
152 meta.maintainers = with lib.maintainers; [ truh anthonyroussel ];