blob: acd9292ceb45c4b05eeb2582b34221fe5009f525 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
{ 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;
defaultText = literalExpression "pkgs.plantuml-server";
description = lib.mdDoc "PlantUML server package to use";
};
packages = {
jdk = mkOption {
type = types.package;
default = pkgs.jdk;
defaultText = literalExpression "pkgs.jdk";
description = lib.mdDoc "JDK package to use for the server";
};
jetty = mkOption {
type = types.package;
default = pkgs.jetty;
defaultText = literalExpression "pkgs.jetty";
description = lib.mdDoc "Jetty package to use for the server";
};
};
user = mkOption {
type = types.str;
default = "plantuml";
description = lib.mdDoc "User which runs PlantUML server.";
};
group = mkOption {
type = types.str;
default = "plantuml";
description = lib.mdDoc "Group which runs PlantUML server.";
};
home = mkOption {
type = types.str;
default = "/var/lib/plantuml";
description = lib.mdDoc "Home directory of the PlantUML server instance.";
};
listenHost = mkOption {
type = types.str;
default = "127.0.0.1";
description = lib.mdDoc "Host to listen on.";
};
listenPort = mkOption {
type = types.int;
default = 8080;
description = lib.mdDoc "Port to listen on.";
};
plantumlLimitSize = mkOption {
type = types.int;
default = 4096;
description = lib.mdDoc "Limits image width and height.";
};
graphvizPackage = mkOption {
type = types.package;
default = pkgs.graphviz;
defaultText = literalExpression "pkgs.graphviz";
description = lib.mdDoc "Package containing the dot executable.";
};
plantumlStats = mkOption {
type = types.bool;
default = false;
description = lib.mdDoc "Set it to on to enable statistics report (https://plantuml.com/statistics-report).";
};
httpAuthorization = mkOption {
type = types.nullOr types.str;
default = null;
description = lib.mdDoc "When calling the proxy endpoint, the value of HTTP_AUTHORIZATION will be used to set the HTTP Authorization header.";
};
allowPlantumlInclude = mkOption {
type = types.bool;
default = false;
description = lib.mdDoc "Enables !include processing which can read files from the server into diagrams. Files are read relative to the current working directory.";
};
};
};
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 = ''
${cfg.packages.jdk}/bin/java \
-jar ${cfg.packages.jetty}/start.jar \
--module=deploy,http,jsp \
jetty.home=${cfg.packages.jetty} \
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 ];
}
|