diff options
author | Minijackson <minijackson@riseup.net> | 2024-05-13 16:04:55 +0200 |
---|---|---|
committer | Minijackson <minijackson@riseup.net> | 2024-05-13 16:04:55 +0200 |
commit | a8da5dbf32870048279626d47bc9587462e7d955 (patch) | |
tree | af2523c68d706b00a1e0845482eee3c0a01e5aa2 /nixos/modules/services/web-servers | |
parent | 31a5a35b7e8515b5941892e1e39a5e8f108f6521 (diff) |
nixos/tomcat: add 'port' option
Diffstat (limited to 'nixos/modules/services/web-servers')
-rw-r--r-- | nixos/modules/services/web-servers/tomcat.nix | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/nixos/modules/services/web-servers/tomcat.nix b/nixos/modules/services/web-servers/tomcat.nix index e243778cc747c..1c5a9af5c9245 100644 --- a/nixos/modules/services/web-servers/tomcat.nix +++ b/nixos/modules/services/web-servers/tomcat.nix @@ -21,6 +21,14 @@ in example = "tomcat10"; }; + port = lib.mkOption { + type = lib.types.port; + default = 8080; + description = '' + The TCP port Tomcat should listen on. + ''; + }; + purifyOnStart = lib.mkOption { type = lib.types.bool; default = false; @@ -244,8 +252,12 @@ in hostElementsString = lib.concatMapStringsSep "\n" hostElementForVirtualHost cfg.virtualHosts; hostElementsSedString = lib.replaceStrings ["\n"] ["\\\n"] hostElementsString; in '' - # Create a modified server.xml which also includes all virtual hosts - sed -e "/<Engine name=\"Catalina\" defaultHost=\"localhost\">/a\\"${lib.escapeShellArg hostElementsSedString} \ + # Create a modified server.xml which listens on the given port, + # and also includes all virtual hosts. + # The host modification must be last here, + # else if hostElementsSedString is empty sed gets confused as to what to append + sed -e 's/<Connector port="8080"/<Connector port="${toString cfg.port}"/' \ + -e "/<Engine name=\"Catalina\" defaultHost=\"localhost\">/a\\"${lib.escapeShellArg hostElementsSedString} \ ${tomcat}/conf/server.xml > ${cfg.baseDir}/conf/server.xml '' } |