at 22.05-pre 3.5 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 7 cfg = config.services.plantuml-server; 8 9in 10 11{ 12 options = { 13 services.plantuml-server = { 14 enable = mkEnableOption "PlantUML server"; 15 16 package = mkOption { 17 type = types.package; 18 default = pkgs.plantuml-server; 19 defaultText = literalExpression "pkgs.plantuml-server"; 20 description = "PlantUML server package to use"; 21 }; 22 23 user = mkOption { 24 type = types.str; 25 default = "plantuml"; 26 description = "User which runs PlantUML server."; 27 }; 28 29 group = mkOption { 30 type = types.str; 31 default = "plantuml"; 32 description = "Group which runs PlantUML server."; 33 }; 34 35 home = mkOption { 36 type = types.str; 37 default = "/var/lib/plantuml"; 38 description = "Home directory of the PlantUML server instance."; 39 }; 40 41 listenHost = mkOption { 42 type = types.str; 43 default = "127.0.0.1"; 44 description = "Host to listen on."; 45 }; 46 47 listenPort = mkOption { 48 type = types.int; 49 default = 8080; 50 description = "Port to listen on."; 51 }; 52 53 plantumlLimitSize = mkOption { 54 type = types.int; 55 default = 4096; 56 description = "Limits image width and height."; 57 }; 58 59 graphvizPackage = mkOption { 60 type = types.package; 61 default = pkgs.graphviz; 62 defaultText = literalExpression "pkgs.graphviz"; 63 description = "Package containing the dot executable."; 64 }; 65 66 plantumlStats = mkOption { 67 type = types.bool; 68 default = false; 69 description = "Set it to on to enable statistics report (https://plantuml.com/statistics-report)."; 70 }; 71 72 httpAuthorization = mkOption { 73 type = types.nullOr types.str; 74 default = null; 75 description = "When calling the proxy endpoint, the value of HTTP_AUTHORIZATION will be used to set the HTTP Authorization header."; 76 }; 77 78 allowPlantumlInclude = mkOption { 79 type = types.bool; 80 default = false; 81 description = "Enables !include processing which can read files from the server into diagrams. Files are read relative to the current working directory."; 82 }; 83 }; 84 }; 85 86 config = mkIf cfg.enable { 87 users.users.${cfg.user} = { 88 isSystemUser = true; 89 group = cfg.group; 90 home = cfg.home; 91 createHome = true; 92 }; 93 94 users.groups.${cfg.group} = {}; 95 96 systemd.services.plantuml-server = { 97 description = "PlantUML server"; 98 wantedBy = [ "multi-user.target" ]; 99 path = [ cfg.home ]; 100 environment = { 101 PLANTUML_LIMIT_SIZE = builtins.toString cfg.plantumlLimitSize; 102 GRAPHVIZ_DOT = "${cfg.graphvizPackage}/bin/dot"; 103 PLANTUML_STATS = if cfg.plantumlStats then "on" else "off"; 104 HTTP_AUTHORIZATION = cfg.httpAuthorization; 105 ALLOW_PLANTUML_INCLUDE = if cfg.allowPlantumlInclude then "true" else "false"; 106 }; 107 script = '' 108 ${pkgs.jre}/bin/java \ 109 -jar ${pkgs.jetty}/start.jar \ 110 --module=deploy,http,jsp \ 111 jetty.home=${pkgs.jetty} \ 112 jetty.base=${cfg.package} \ 113 jetty.http.host=${cfg.listenHost} \ 114 jetty.http.port=${builtins.toString cfg.listenPort} 115 ''; 116 serviceConfig = { 117 User = cfg.user; 118 Group = cfg.group; 119 PrivateTmp = true; 120 }; 121 }; 122 }; 123 124 meta.maintainers = with lib.maintainers; [ truh ]; 125}