Merge pull request #267560 from anthonyroussel/bugfix/plantuml-server-nixos
nixos/plantuml-server: fix
This commit is contained in:
commit
3acc2484cf
8 changed files with 111 additions and 58 deletions
|
@ -1,123 +1,110 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
|
||||||
|
|
||||||
let
|
let
|
||||||
|
inherit (lib)
|
||||||
|
literalExpression
|
||||||
|
mdDoc
|
||||||
|
mkEnableOption
|
||||||
|
mkIf
|
||||||
|
mkOption
|
||||||
|
mkPackageOptionMD
|
||||||
|
mkRemovedOptionModule
|
||||||
|
types
|
||||||
|
;
|
||||||
|
|
||||||
cfg = config.services.plantuml-server;
|
cfg = config.services.plantuml-server;
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
|
imports = [
|
||||||
|
(mkRemovedOptionModule [ "services" "plantuml-server" "allowPlantumlInclude" ] "This option has been removed from PlantUML.")
|
||||||
|
];
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
services.plantuml-server = {
|
services.plantuml-server = {
|
||||||
enable = mkEnableOption (lib.mdDoc "PlantUML server");
|
enable = mkEnableOption (mdDoc "PlantUML server");
|
||||||
|
|
||||||
package = mkOption {
|
package = mkPackageOptionMD pkgs "plantuml-server" { };
|
||||||
type = types.package;
|
|
||||||
default = pkgs.plantuml-server;
|
|
||||||
defaultText = literalExpression "pkgs.plantuml-server";
|
|
||||||
description = lib.mdDoc "PlantUML server package to use";
|
|
||||||
};
|
|
||||||
|
|
||||||
packages = {
|
packages = {
|
||||||
jdk = mkOption {
|
jdk = mkPackageOptionMD pkgs "jdk" { };
|
||||||
type = types.package;
|
jetty = mkPackageOptionMD pkgs "jetty" {
|
||||||
default = pkgs.jdk;
|
default = "jetty_11";
|
||||||
defaultText = literalExpression "pkgs.jdk";
|
extraDescription = ''
|
||||||
description = lib.mdDoc "JDK package to use for the server";
|
At the time of writing (v1.2023.12), PlantUML Server does not support
|
||||||
};
|
Jetty versions higher than 12.x.
|
||||||
jetty = mkOption {
|
|
||||||
type = types.package;
|
Jetty 12.x has introduced major breaking changes, see
|
||||||
default = pkgs.jetty;
|
<https://github.com/jetty/jetty.project/releases/tag/jetty-12.0.0> and
|
||||||
defaultText = literalExpression "pkgs.jetty";
|
<https://eclipse.dev/jetty/documentation/jetty-12/programming-guide/index.html#pg-migration-11-to-12>
|
||||||
description = lib.mdDoc "Jetty package to use for the server";
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
user = mkOption {
|
user = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "plantuml";
|
default = "plantuml";
|
||||||
description = lib.mdDoc "User which runs PlantUML server.";
|
description = mdDoc "User which runs PlantUML server.";
|
||||||
};
|
};
|
||||||
|
|
||||||
group = mkOption {
|
group = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "plantuml";
|
default = "plantuml";
|
||||||
description = lib.mdDoc "Group which runs PlantUML server.";
|
description = mdDoc "Group which runs PlantUML server.";
|
||||||
};
|
};
|
||||||
|
|
||||||
home = mkOption {
|
home = mkOption {
|
||||||
type = types.str;
|
type = types.path;
|
||||||
default = "/var/lib/plantuml";
|
default = "/var/lib/plantuml";
|
||||||
description = lib.mdDoc "Home directory of the PlantUML server instance.";
|
description = mdDoc "Home directory of the PlantUML server instance.";
|
||||||
};
|
};
|
||||||
|
|
||||||
listenHost = mkOption {
|
listenHost = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "127.0.0.1";
|
default = "127.0.0.1";
|
||||||
description = lib.mdDoc "Host to listen on.";
|
description = mdDoc "Host to listen on.";
|
||||||
};
|
};
|
||||||
|
|
||||||
listenPort = mkOption {
|
listenPort = mkOption {
|
||||||
type = types.int;
|
type = types.int;
|
||||||
default = 8080;
|
default = 8080;
|
||||||
description = lib.mdDoc "Port to listen on.";
|
description = mdDoc "Port to listen on.";
|
||||||
};
|
};
|
||||||
|
|
||||||
plantumlLimitSize = mkOption {
|
plantumlLimitSize = mkOption {
|
||||||
type = types.int;
|
type = types.int;
|
||||||
default = 4096;
|
default = 4096;
|
||||||
description = lib.mdDoc "Limits image width and height.";
|
description = mdDoc "Limits image width and height.";
|
||||||
};
|
};
|
||||||
|
|
||||||
graphvizPackage = mkOption {
|
graphvizPackage = mkPackageOptionMD pkgs "graphviz" { };
|
||||||
type = types.package;
|
|
||||||
default = pkgs.graphviz;
|
|
||||||
defaultText = literalExpression "pkgs.graphviz";
|
|
||||||
description = lib.mdDoc "Package containing the dot executable.";
|
|
||||||
};
|
|
||||||
|
|
||||||
plantumlStats = mkOption {
|
plantumlStats = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = lib.mdDoc "Set it to on to enable statistics report (https://plantuml.com/statistics-report).";
|
description = mdDoc "Set it to on to enable statistics report (https://plantuml.com/statistics-report).";
|
||||||
};
|
};
|
||||||
|
|
||||||
httpAuthorization = mkOption {
|
httpAuthorization = mkOption {
|
||||||
type = types.nullOr types.str;
|
type = types.nullOr types.str;
|
||||||
default = null;
|
default = null;
|
||||||
description = lib.mdDoc "When calling the proxy endpoint, the value of HTTP_AUTHORIZATION will be used to set the HTTP Authorization header.";
|
description = 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 {
|
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 = {
|
systemd.services.plantuml-server = {
|
||||||
description = "PlantUML server";
|
description = "PlantUML server";
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
path = [ cfg.home ];
|
path = [ cfg.home ];
|
||||||
|
|
||||||
environment = {
|
environment = {
|
||||||
PLANTUML_LIMIT_SIZE = builtins.toString cfg.plantumlLimitSize;
|
PLANTUML_LIMIT_SIZE = builtins.toString cfg.plantumlLimitSize;
|
||||||
GRAPHVIZ_DOT = "${cfg.graphvizPackage}/bin/dot";
|
GRAPHVIZ_DOT = "${cfg.graphvizPackage}/bin/dot";
|
||||||
PLANTUML_STATS = if cfg.plantumlStats then "on" else "off";
|
PLANTUML_STATS = if cfg.plantumlStats then "on" else "off";
|
||||||
HTTP_AUTHORIZATION = cfg.httpAuthorization;
|
HTTP_AUTHORIZATION = cfg.httpAuthorization;
|
||||||
ALLOW_PLANTUML_INCLUDE = if cfg.allowPlantumlInclude then "true" else "false";
|
|
||||||
};
|
};
|
||||||
script = ''
|
script = ''
|
||||||
${cfg.packages.jdk}/bin/java \
|
${cfg.packages.jdk}/bin/java \
|
||||||
|
@ -128,13 +115,40 @@ in
|
||||||
jetty.http.host=${cfg.listenHost} \
|
jetty.http.host=${cfg.listenHost} \
|
||||||
jetty.http.port=${builtins.toString cfg.listenPort}
|
jetty.http.port=${builtins.toString cfg.listenPort}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
User = cfg.user;
|
User = cfg.user;
|
||||||
Group = cfg.group;
|
Group = cfg.group;
|
||||||
|
StateDirectory = mkIf (cfg.home == "/var/lib/plantuml") "plantuml";
|
||||||
|
StateDirectoryMode = mkIf (cfg.home == "/var/lib/plantuml") "0750";
|
||||||
|
|
||||||
|
# Hardening
|
||||||
|
AmbientCapabilities = [ "" ];
|
||||||
|
CapabilityBoundingSet = [ "" ];
|
||||||
|
DynamicUser = true;
|
||||||
|
LockPersonality = true;
|
||||||
|
NoNewPrivileges = true;
|
||||||
|
PrivateDevices = true;
|
||||||
|
PrivateNetwork = false;
|
||||||
PrivateTmp = true;
|
PrivateTmp = true;
|
||||||
|
PrivateUsers = true;
|
||||||
|
ProtectClock = true;
|
||||||
|
ProtectControlGroups = true;
|
||||||
|
ProtectHome = true;
|
||||||
|
ProtectHostname = true;
|
||||||
|
ProtectKernelLogs = true;
|
||||||
|
ProtectKernelModules = true;
|
||||||
|
ProtectKernelTunables = true;
|
||||||
|
ProtectSystem = "strict";
|
||||||
|
RestrictAddressFamilies = [ "AF_UNIX" "AF_INET" "AF_INET6" ];
|
||||||
|
RestrictNamespaces = true;
|
||||||
|
RestrictRealtime = true;
|
||||||
|
RestrictSUIDSGID = true;
|
||||||
|
SystemCallArchitectures = "native";
|
||||||
|
SystemCallFilter = [ "@system-service" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
meta.maintainers = with lib.maintainers; [ truh ];
|
meta.maintainers = with lib.maintainers; [ truh anthonyroussel ];
|
||||||
}
|
}
|
||||||
|
|
|
@ -656,6 +656,7 @@ in {
|
||||||
phylactery = handleTest ./web-apps/phylactery.nix {};
|
phylactery = handleTest ./web-apps/phylactery.nix {};
|
||||||
pict-rs = handleTest ./pict-rs.nix {};
|
pict-rs = handleTest ./pict-rs.nix {};
|
||||||
pinnwand = handleTest ./pinnwand.nix {};
|
pinnwand = handleTest ./pinnwand.nix {};
|
||||||
|
plantuml-server = handleTest ./plantuml-server.nix {};
|
||||||
plasma-bigscreen = handleTest ./plasma-bigscreen.nix {};
|
plasma-bigscreen = handleTest ./plasma-bigscreen.nix {};
|
||||||
plasma5 = handleTest ./plasma5.nix {};
|
plasma5 = handleTest ./plasma5.nix {};
|
||||||
plasma5-systemd-start = handleTest ./plasma5-systemd-start.nix {};
|
plasma5-systemd-start = handleTest ./plasma5-systemd-start.nix {};
|
||||||
|
|
20
nixos/tests/plantuml-server.nix
Normal file
20
nixos/tests/plantuml-server.nix
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
import ./make-test-python.nix ({ pkgs, lib, ... }: {
|
||||||
|
name = "plantuml-server";
|
||||||
|
meta.maintainers = with lib.maintainers; [ anthonyroussel ];
|
||||||
|
|
||||||
|
nodes.machine = { pkgs, ... }: {
|
||||||
|
environment.systemPackages = [ pkgs.curl ];
|
||||||
|
services.plantuml-server.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
testScript = ''
|
||||||
|
start_all()
|
||||||
|
|
||||||
|
machine.wait_for_unit("plantuml-server.service")
|
||||||
|
machine.wait_for_open_port(8080)
|
||||||
|
|
||||||
|
with subtest("Generate chart"):
|
||||||
|
chart_id = machine.succeed("curl -sSf http://localhost:8080/plantuml/coder -d 'Alice -> Bob'")
|
||||||
|
machine.succeed("curl -sSf http://localhost:8080/plantuml/txt/{}".format(chart_id))
|
||||||
|
'';
|
||||||
|
})
|
4
pkgs/servers/http/jetty/11.x.nix
Normal file
4
pkgs/servers/http/jetty/11.x.nix
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
import ./common.nix {
|
||||||
|
version = "11.0.18";
|
||||||
|
hash = "sha256-HxtO2r6YWo6+MAYUgk7dNSPDqQZoyO9t/8NdI5pPkL4=";
|
||||||
|
}
|
4
pkgs/servers/http/jetty/12.x.nix
Normal file
4
pkgs/servers/http/jetty/12.x.nix
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
import ./common.nix {
|
||||||
|
version = "12.0.3";
|
||||||
|
hash = "sha256-Z/jJKKzoqTPZnoFOMwbpSd/Kd1w+rXloKH+aw6aNrKs=";
|
||||||
|
}
|
|
@ -1,11 +1,15 @@
|
||||||
|
{ version, hash }:
|
||||||
|
|
||||||
{ lib, stdenv, fetchurl }:
|
{ lib, stdenv, fetchurl }:
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
pname = "jetty";
|
pname = "jetty";
|
||||||
version = "12.0.2";
|
|
||||||
|
inherit version;
|
||||||
|
|
||||||
src = fetchurl {
|
src = fetchurl {
|
||||||
url = "mirror://maven/org/eclipse/jetty/jetty-home/${version}/jetty-home-${version}.tar.gz";
|
url = "mirror://maven/org/eclipse/jetty/jetty-home/${version}/jetty-home-${version}.tar.gz";
|
||||||
hash = "sha256-DtlHTXjbr31RmK6ycDdiWOL7jIpbWNh0la90OnOhzvM=";
|
inherit hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
dontBuild = true;
|
dontBuild = true;
|
||||||
|
@ -17,10 +21,10 @@ stdenv.mkDerivation rec {
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "A Web server and javax.servlet container";
|
description = "A Web server and javax.servlet container";
|
||||||
homepage = "https://www.eclipse.org/jetty/";
|
homepage = "https://eclipse.dev/jetty/";
|
||||||
platforms = platforms.all;
|
platforms = platforms.all;
|
||||||
sourceProvenance = with sourceTypes; [ binaryBytecode ];
|
sourceProvenance = with sourceTypes; [ binaryBytecode ];
|
||||||
license = with licenses; [ asl20 epl10 ];
|
license = with licenses; [ asl20 epl10 ];
|
||||||
maintainers = with maintainers; [ emmanuelrosa ];
|
maintainers = with maintainers; [ emmanuelrosa anthonyroussel ];
|
||||||
};
|
};
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
{ lib, stdenv, fetchurl }:
|
{ lib, stdenv, fetchurl, nixosTests }:
|
||||||
|
|
||||||
let
|
let
|
||||||
version = "1.2023.12";
|
version = "1.2023.12";
|
||||||
|
@ -17,6 +17,10 @@ stdenv.mkDerivation rec {
|
||||||
cp "$src" "$out/webapps/plantuml.war"
|
cp "$src" "$out/webapps/plantuml.war"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
passthru.tests = {
|
||||||
|
inherit (nixosTests) plantuml-server;
|
||||||
|
};
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "A web application to generate UML diagrams on-the-fly.";
|
description = "A web application to generate UML diagrams on-the-fly.";
|
||||||
homepage = "https://plantuml.com/";
|
homepage = "https://plantuml.com/";
|
||||||
|
|
|
@ -26531,7 +26531,9 @@ with pkgs;
|
||||||
|
|
||||||
jboss_mysql_jdbc = callPackage ../servers/http/jboss/jdbc/mysql { };
|
jboss_mysql_jdbc = callPackage ../servers/http/jboss/jdbc/mysql { };
|
||||||
|
|
||||||
jetty = callPackage ../servers/http/jetty { };
|
jetty = jetty_12;
|
||||||
|
jetty_12 = callPackage ../servers/http/jetty/12.x.nix { };
|
||||||
|
jetty_11 = callPackage ../servers/http/jetty/11.x.nix { };
|
||||||
|
|
||||||
jibri = callPackage ../servers/jibri { };
|
jibri = callPackage ../servers/jibri { };
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue