From 5b146274aef03bfc6b964d8089090d9ae050f47b Mon Sep 17 00:00:00 2001 From: Anthony Roussel Date: Thu, 26 Oct 2023 07:20:56 +0200 Subject: [PATCH 1/9] axis2: 1.7.9 -> 1.8.2 https://github.com/apache/axis-axis2-java-core/compare/v1.7.9...v1.8.2 --- pkgs/servers/http/tomcat/axis2/default.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/servers/http/tomcat/axis2/default.nix b/pkgs/servers/http/tomcat/axis2/default.nix index 4bca9a37a9ce..8ca1e56e883f 100644 --- a/pkgs/servers/http/tomcat/axis2/default.nix +++ b/pkgs/servers/http/tomcat/axis2/default.nix @@ -2,11 +2,11 @@ stdenv.mkDerivation rec { pname = "axis2"; - version = "1.7.9"; + version = "1.8.2"; src = fetchurl { - url = "http://apache.proserve.nl/axis/axis2/java/core/${version}/${pname}-${version}-bin.zip"; - sha256 = "0dh0s9bfh95wmmw8nyf2yw95biq7d9zmrbg8k4vzcyz1if228lac"; + url = "mirror://apache/axis/axis2/java/core/${version}/${pname}-${version}-bin.zip"; + hash = "sha256-oilPVFFpl3F61nVDxcYx/bc81FopS5fzoIdXzeP8brk="; }; nativeBuildInputs = [ unzip ]; @@ -15,6 +15,8 @@ stdenv.mkDerivation rec { meta = { description = "Web Services / SOAP / WSDL engine, the successor to the widely used Apache Axis SOAP stack"; + homepage = "https://axis.apache.org/axis2/java/core/"; + maintainers = [ ]; platforms = lib.platforms.unix; sourceProvenance = with lib.sourceTypes; [ binaryBytecode ]; license = lib.licenses.asl20; From 789fe864db6ce585fa6ee811e5dae9b4438ddeaf Mon Sep 17 00:00:00 2001 From: Anthony Roussel Date: Thu, 26 Oct 2023 11:00:47 +0200 Subject: [PATCH 2/9] axis2: add meta.changelog --- pkgs/servers/http/tomcat/axis2/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/servers/http/tomcat/axis2/default.nix b/pkgs/servers/http/tomcat/axis2/default.nix index 8ca1e56e883f..ba35edc9017d 100644 --- a/pkgs/servers/http/tomcat/axis2/default.nix +++ b/pkgs/servers/http/tomcat/axis2/default.nix @@ -16,6 +16,7 @@ stdenv.mkDerivation rec { meta = { description = "Web Services / SOAP / WSDL engine, the successor to the widely used Apache Axis SOAP stack"; homepage = "https://axis.apache.org/axis2/java/core/"; + changelog = "https://axis.apache.org/axis2/java/core/release-notes/${version}.html"; maintainers = [ ]; platforms = lib.platforms.unix; sourceProvenance = with lib.sourceTypes; [ binaryBytecode ]; From 6b6bc55a6f943115acd0e69a4eb1bce08da39b3e Mon Sep 17 00:00:00 2001 From: Anthony Roussel Date: Thu, 26 Oct 2023 11:01:09 +0200 Subject: [PATCH 3/9] nixosTests.tomcat: test Apache Axis2 container integration --- nixos/tests/tomcat.nix | 17 +++++++++++------ pkgs/servers/http/tomcat/default.nix | 6 +++++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/nixos/tests/tomcat.nix b/nixos/tests/tomcat.nix index 4cfb3cc5a7d8..a5f219e104ad 100644 --- a/nixos/tests/tomcat.nix +++ b/nixos/tests/tomcat.nix @@ -1,21 +1,26 @@ -import ./make-test-python.nix ({ pkgs, ... }: - -{ +import ./make-test-python.nix ({ pkgs, ... }: { name = "tomcat"; nodes.machine = { pkgs, ... }: { - services.tomcat.enable = true; + services.tomcat = { + enable = true; + axis2.enable = true; + }; }; testScript = '' machine.wait_for_unit("tomcat.service") machine.wait_for_open_port(8080) machine.wait_for_file("/var/tomcat/webapps/examples"); + machine.succeed( - "curl --fail http://localhost:8080/examples/servlets/servlet/HelloWorldExample | grep 'Hello World!'" + "curl -sS --fail http://localhost:8080/examples/servlets/servlet/HelloWorldExample | grep 'Hello World!'" ) machine.succeed( - "curl --fail http://localhost:8080/examples/jsp/jsp2/simpletag/hello.jsp | grep 'Hello, world!'" + "curl -sS --fail http://localhost:8080/examples/jsp/jsp2/simpletag/hello.jsp | grep 'Hello, world!'" + ) + machine.succeed( + "curl -sS --fail http://localhost:8080/axis2/axis2-web/HappyAxis.jsp | grep 'Found Axis2'" ) ''; }) diff --git a/pkgs/servers/http/tomcat/default.nix b/pkgs/servers/http/tomcat/default.nix index ede01d350d4b..f57645d85801 100644 --- a/pkgs/servers/http/tomcat/default.nix +++ b/pkgs/servers/http/tomcat/default.nix @@ -1,4 +1,4 @@ -{ stdenv, lib, fetchurl }: +{ stdenv, lib, fetchurl, nixosTests }: let @@ -20,6 +20,10 @@ let mv $out/webapps $webapps/ ''; + passthru.tests = { + inherit (nixosTests) tomcat; + }; + meta = with lib; { homepage = "https://tomcat.apache.org/"; description = "An implementation of the Java Servlet and JavaServer Pages technologies"; From 0908cc1a9e89a3ac1757a0399c5d9db41fa07d1c Mon Sep 17 00:00:00 2001 From: Anthony Roussel Date: Thu, 26 Oct 2023 11:06:32 +0200 Subject: [PATCH 4/9] nixos/tomcat: remove `with lib;` and use mkEnableOption --- nixos/modules/services/web-servers/tomcat.nix | 165 ++++++++---------- 1 file changed, 70 insertions(+), 95 deletions(-) diff --git a/nixos/modules/services/web-servers/tomcat.nix b/nixos/modules/services/web-servers/tomcat.nix index 4d2c36287be6..30d6b99fcfda 100644 --- a/nixos/modules/services/web-servers/tomcat.nix +++ b/nixos/modules/services/web-servers/tomcat.nix @@ -1,7 +1,5 @@ { config, lib, pkgs, ... }: -with lib; - let cfg = config.services.tomcat; @@ -9,30 +7,20 @@ let in { - meta = { - maintainers = with maintainers; [ danbst ]; + maintainers = with lib.maintainers; [ danbst ]; }; ###### interface options = { - services.tomcat = { - enable = mkEnableOption (lib.mdDoc "Apache Tomcat"); + enable = lib.mkEnableOption (lib.mdDoc "Apache Tomcat"); - package = mkOption { - type = types.package; - default = pkgs.tomcat9; - defaultText = literalExpression "pkgs.tomcat9"; - example = lib.literalExpression "pkgs.tomcat9"; - description = lib.mdDoc '' - Which tomcat package to use. - ''; - }; + package = lib.mkPackageOptionMD pkgs "tomcat9" { }; - purifyOnStart = mkOption { - type = types.bool; + purifyOnStart = lib.mkOption { + type = lib.types.bool; default = false; description = lib.mdDoc '' On startup, the `baseDir` directory is populated with various files, @@ -43,7 +31,7 @@ in ''; }; - baseDir = mkOption { + baseDir = lib.mkOption { type = lib.types.path; default = "/var/tomcat"; description = lib.mdDoc '' @@ -53,64 +41,64 @@ in ''; }; - logDirs = mkOption { - default = []; - type = types.listOf types.path; + logDirs = lib.mkOption { + default = [ ]; + type = lib.types.listOf lib.types.path; description = lib.mdDoc "Directories to create in baseDir/logs/"; }; - extraConfigFiles = mkOption { - default = []; - type = types.listOf types.path; + extraConfigFiles = lib.mkOption { + default = [ ]; + type = lib.types.listOf lib.types.path; description = lib.mdDoc "Extra configuration files to pull into the tomcat conf directory"; }; - extraEnvironment = mkOption { - type = types.listOf types.str; - default = []; + extraEnvironment = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ ]; example = [ "ENVIRONMENT=production" ]; description = lib.mdDoc "Environment Variables to pass to the tomcat service"; }; - extraGroups = mkOption { - default = []; - type = types.listOf types.str; + extraGroups = lib.mkOption { + default = [ ]; + type = lib.types.listOf lib.types.str; example = [ "users" ]; description = lib.mdDoc "Defines extra groups to which the tomcat user belongs."; }; - user = mkOption { - type = types.str; + user = lib.mkOption { + type = lib.types.str; default = "tomcat"; description = lib.mdDoc "User account under which Apache Tomcat runs."; }; - group = mkOption { - type = types.str; + group = lib.mkOption { + type = lib.types.str; default = "tomcat"; description = lib.mdDoc "Group account under which Apache Tomcat runs."; }; - javaOpts = mkOption { - type = types.either (types.listOf types.str) types.str; + javaOpts = lib.mkOption { + type = lib.types.either (lib.types.listOf lib.types.str) lib.types.str; default = ""; description = lib.mdDoc "Parameters to pass to the Java Virtual Machine which spawns Apache Tomcat"; }; - catalinaOpts = mkOption { - type = types.either (types.listOf types.str) types.str; + catalinaOpts = lib.mkOption { + type = lib.types.either (lib.types.listOf lib.types.str) lib.types.str; default = ""; description = lib.mdDoc "Parameters to pass to the Java Virtual Machine which spawns the Catalina servlet container"; }; - sharedLibs = mkOption { - type = types.listOf types.str; - default = []; + sharedLibs = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ ]; description = lib.mdDoc "List containing JAR files or directories with JAR files which are libraries shared by the web applications"; }; - serverXml = mkOption { - type = types.lines; + serverXml = lib.mkOption { + type = lib.types.lines; default = ""; description = lib.mdDoc '' Verbatim server.xml configuration. @@ -118,87 +106,74 @@ in ''; }; - commonLibs = mkOption { - type = types.listOf types.str; - default = []; + commonLibs = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ ]; description = lib.mdDoc "List containing JAR files or directories with JAR files which are libraries shared by the web applications and the servlet container"; }; - webapps = mkOption { - type = types.listOf types.path; + webapps = lib.mkOption { + type = lib.types.listOf lib.types.path; default = [ tomcat.webapps ]; - defaultText = literalExpression "[ config.services.tomcat.package.webapps ]"; + defaultText = lib.literalExpression "[ config.services.tomcat.package.webapps ]"; description = lib.mdDoc "List containing WAR files or directories with WAR files which are web applications to be deployed on Tomcat"; }; - virtualHosts = mkOption { - type = types.listOf (types.submodule { + virtualHosts = lib.mkOption { + type = lib.types.listOf (lib.types.submodule { options = { - name = mkOption { - type = types.str; + name = lib.mkOption { + type = lib.types.str; description = lib.mdDoc "name of the virtualhost"; }; - aliases = mkOption { - type = types.listOf types.str; + aliases = lib.mkOption { + type = lib.types.listOf lib.types.str; description = lib.mdDoc "aliases of the virtualhost"; - default = []; + default = [ ]; }; - webapps = mkOption { - type = types.listOf types.path; + webapps = lib.mkOption { + type = lib.types.listOf lib.types.path; description = lib.mdDoc '' List containing web application WAR files and/or directories containing web applications and configuration files for the virtual host. ''; - default = []; + default = [ ]; }; }; }); - default = []; + default = [ ]; description = lib.mdDoc "List consisting of a virtual host name and a list of web applications to deploy on each virtual host"; }; - logPerVirtualHost = mkOption { - type = types.bool; + logPerVirtualHost = lib.mkOption { + type = lib.types.bool; default = false; description = lib.mdDoc "Whether to enable logging per virtual host."; }; - jdk = mkOption { - type = types.package; - default = pkgs.jdk; - defaultText = literalExpression "pkgs.jdk"; - description = lib.mdDoc "Which JDK to use."; - }; + jdk = lib.mkPackageOptionMD pkgs "jdk" { }; axis2 = { + enable = lib.mkEnableOption "Apache Axis2 container"; - enable = mkOption { - default = false; - type = types.bool; - description = lib.mdDoc "Whether to enable an Apache Axis2 container"; - }; - - services = mkOption { - default = []; - type = types.listOf types.str; + services = lib.mkOption { + default = [ ]; + type = lib.types.listOf lib.types.str; description = lib.mdDoc "List containing AAR files or directories with AAR files which are web services to be deployed on Axis2"; }; - }; - }; - }; - ###### implementation - config = mkIf config.services.tomcat.enable { + config = lib.mkIf config.services.tomcat.enable { users.groups.tomcat.gid = config.ids.gids.tomcat; users.users.tomcat = - { uid = config.ids.uids.tomcat; + { + uid = config.ids.uids.tomcat; description = "Tomcat user"; home = "/homeless-shelter"; group = "tomcat"; @@ -234,7 +209,7 @@ in ln -sfn ${tomcat}/conf/$i ${cfg.baseDir}/conf/`basename $i` done - ${optionalString (cfg.extraConfigFiles != []) '' + ${lib.optionalString (cfg.extraConfigFiles != []) '' for i in ${toString cfg.extraConfigFiles}; do ln -sfn $i ${cfg.baseDir}/conf/`basename $i` done @@ -253,32 +228,32 @@ in hostElementForVirtualHost = virtualHost: '' - '' + concatStrings (innerElementsForVirtualHost virtualHost) + '' + '' + lib.concatStrings (innerElementsForVirtualHost virtualHost) + '' ''; innerElementsForVirtualHost = virtualHost: (map (alias: '' ${alias} '') virtualHost.aliases) - ++ (optional cfg.logPerVirtualHost '' + ++ (lib.optional cfg.logPerVirtualHost '' ''); - hostElementsString = concatMapStringsSep "\n" hostElementForVirtualHost cfg.virtualHosts; - hostElementsSedString = replaceStrings ["\n"] ["\\\n"] hostElementsString; + 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 "//a\\"${escapeShellArg hostElementsSedString} \ + sed -e "//a\\"${lib.escapeShellArg hostElementsSedString} \ ${tomcat}/conf/server.xml > ${cfg.baseDir}/conf/server.xml '' } - ${optionalString (cfg.logDirs != []) '' + ${lib.optionalString (cfg.logDirs != []) '' for i in ${toString cfg.logDirs}; do mkdir -p ${cfg.baseDir}/logs/$i chown ${cfg.user}:${cfg.group} ${cfg.baseDir}/logs/$i done ''} - ${optionalString cfg.logPerVirtualHost (toString (map (h: '' + ${lib.optionalString cfg.logPerVirtualHost (toString (map (h: '' mkdir -p ${cfg.baseDir}/logs/${h.name} chown ${cfg.user}:${cfg.group} ${cfg.baseDir}/logs/${h.name} '') cfg.virtualHosts))} @@ -345,7 +320,7 @@ in # Symlink all the given web applications files or paths into the webapps/ directory # of this virtual host - for i in "${optionalString (virtualHost ? webapps) (toString virtualHost.webapps)}"; do + for i in "${lib.optionalString (virtualHost ? webapps) (toString virtualHost.webapps)}"; do if [ -f $i ]; then # If the given web application is a file, symlink it into the webapps/ directory ln -sfn $i ${cfg.baseDir}/virtualhosts/${virtualHost.name}/webapps/`basename $i` @@ -368,7 +343,7 @@ in done '') cfg.virtualHosts)} - ${optionalString cfg.axis2.enable '' + ${lib.optionalString cfg.axis2.enable '' # Copy the Axis2 web application cp -av ${pkgs.axis2}/webapps/axis2 ${cfg.baseDir}/webapps @@ -405,10 +380,10 @@ in serviceConfig = { Type = "forking"; PermissionsStartOnly = true; - PIDFile="/run/tomcat/tomcat.pid"; + PIDFile = "/run/tomcat/tomcat.pid"; RuntimeDirectory = "tomcat"; User = cfg.user; - Environment=[ + Environment = [ "CATALINA_BASE=${cfg.baseDir}" "CATALINA_PID=/run/tomcat/tomcat.pid" "JAVA_HOME='${cfg.jdk}'" From 3655470d18d4941ee6f893eeec8f82d0d7d577ce Mon Sep 17 00:00:00 2001 From: Anthony Roussel Date: Thu, 26 Oct 2023 11:12:04 +0200 Subject: [PATCH 5/9] tomcat9: 9.0.75 -> 9.0.82 https://tomcat.apache.org/tomcat-9.0-doc/changelog.html --- pkgs/servers/http/tomcat/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/servers/http/tomcat/default.nix b/pkgs/servers/http/tomcat/default.nix index f57645d85801..969a0587757f 100644 --- a/pkgs/servers/http/tomcat/default.nix +++ b/pkgs/servers/http/tomcat/default.nix @@ -37,8 +37,8 @@ let in { tomcat9 = common { versionMajor = "9"; - versionMinor = "0.75"; - sha256 = "sha256-VWfKg789z+ns1g3hDsCZFYQ+PsdqUEBeBHCihkGZelk="; + versionMinor = "0.82"; + sha256 = "sha256-xvRGXDUkYaHFYacUPg81Xf0xyTbdsc1XP/PmqMR8bQc="; }; tomcat10 = common { From 0031faaecafd2344c531edde932afc67508640f0 Mon Sep 17 00:00:00 2001 From: Anthony Roussel Date: Thu, 26 Oct 2023 11:12:17 +0200 Subject: [PATCH 6/9] tomcat10: 10.0.27 -> 10.1.15 https://tomcat.apache.org/tomcat-10.1-doc/changelog.html --- pkgs/servers/http/tomcat/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/servers/http/tomcat/default.nix b/pkgs/servers/http/tomcat/default.nix index 969a0587757f..9872cf9e8e0f 100644 --- a/pkgs/servers/http/tomcat/default.nix +++ b/pkgs/servers/http/tomcat/default.nix @@ -43,7 +43,7 @@ in { tomcat10 = common { versionMajor = "10"; - versionMinor = "0.27"; - sha256 = "sha256-N2atmOdhVrGx88eXOc9Wziq8kn7IWzTeFyFpir/5HLc="; + versionMinor = "1.15"; + sha256 = "sha256-cqQW3Dc3sC/1zoidMIGDBNw4G5bnxYvhmHz7U7K6Djg="; }; } From a4f37c8896be3003cd0f0882a46a8ba1fc81c5ad Mon Sep 17 00:00:00 2001 From: Anthony Roussel Date: Thu, 26 Oct 2023 12:09:11 +0200 Subject: [PATCH 7/9] tomcat{9,10}: add passthru.tests.version --- pkgs/servers/http/tomcat/default.nix | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkgs/servers/http/tomcat/default.nix b/pkgs/servers/http/tomcat/default.nix index 9872cf9e8e0f..af735eebd348 100644 --- a/pkgs/servers/http/tomcat/default.nix +++ b/pkgs/servers/http/tomcat/default.nix @@ -1,13 +1,13 @@ -{ stdenv, lib, fetchurl, nixosTests }: +{ stdenv, lib, fetchurl, nixosTests, testers, jre }: let - common = { versionMajor, versionMinor, sha256 }: stdenv.mkDerivation (rec { + common = { versionMajor, versionMinor, sha256 }: stdenv.mkDerivation (finalAttrs: { pname = "apache-tomcat"; version = "${versionMajor}.${versionMinor}"; src = fetchurl { - url = "mirror://apache/tomcat/tomcat-${versionMajor}/v${version}/bin/${pname}-${version}.tar.gz"; + url = "mirror://apache/tomcat/tomcat-${versionMajor}/v${finalAttrs.version}/bin/${finalAttrs.pname}-${finalAttrs.version}.tar.gz"; inherit sha256; }; @@ -22,6 +22,10 @@ let passthru.tests = { inherit (nixosTests) tomcat; + version = testers.testVersion { + package = finalAttrs.finalPackage; + command = "JAVA_HOME=${jre} ${finalAttrs.finalPackage}/bin/version.sh"; + }; }; meta = with lib; { From 9489fc779e2ed2c6536ead22b0fd8192ad4e80fe Mon Sep 17 00:00:00 2001 From: Anthony Roussel Date: Tue, 7 Nov 2023 11:38:34 +0100 Subject: [PATCH 8/9] axis2: add anthonyroussel to maintainers --- pkgs/servers/http/tomcat/axis2/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/servers/http/tomcat/axis2/default.nix b/pkgs/servers/http/tomcat/axis2/default.nix index ba35edc9017d..5cee9020b8aa 100644 --- a/pkgs/servers/http/tomcat/axis2/default.nix +++ b/pkgs/servers/http/tomcat/axis2/default.nix @@ -17,7 +17,7 @@ stdenv.mkDerivation rec { description = "Web Services / SOAP / WSDL engine, the successor to the widely used Apache Axis SOAP stack"; homepage = "https://axis.apache.org/axis2/java/core/"; changelog = "https://axis.apache.org/axis2/java/core/release-notes/${version}.html"; - maintainers = [ ]; + maintainers = [ lib.maintainers.anthonyroussel ]; platforms = lib.platforms.unix; sourceProvenance = with lib.sourceTypes; [ binaryBytecode ]; license = lib.licenses.asl20; From e5ae8202f71730f7f1a14f783af924355194724c Mon Sep 17 00:00:00 2001 From: Anthony Roussel Date: Tue, 7 Nov 2023 11:38:55 +0100 Subject: [PATCH 9/9] tomcat{9,10}: add anthonyroussel to maintainers --- pkgs/servers/http/tomcat/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/servers/http/tomcat/default.nix b/pkgs/servers/http/tomcat/default.nix index af735eebd348..0b1d4115c895 100644 --- a/pkgs/servers/http/tomcat/default.nix +++ b/pkgs/servers/http/tomcat/default.nix @@ -32,7 +32,7 @@ let homepage = "https://tomcat.apache.org/"; description = "An implementation of the Java Servlet and JavaServer Pages technologies"; platforms = platforms.all; - maintainers = [ ]; + maintainers = with maintainers; [ anthonyroussel ]; license = [ licenses.asl20 ]; sourceProvenance = with sourceTypes; [ binaryBytecode ]; };