commit:     34d5c86f4a236cd08c2eae2abe4cb9c3b9395d68
Author:     Zurab Kvachadze <zurabid2016 <AT> gmail <DOT> com>
AuthorDate: Sun Feb  8 19:01:58 2026 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Feb 20 19:09:34 2026 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=34d5c86f

nginx.eclass: Support /etc/nginx/modules-{available,enabled}

This directory layout allows for more flexible dynamic module
management. nginx-module.eclass generates `load_module` .conf stubs for
every module and installs them into /etc/nginx/modules-available. Then,
modules can be enabled or disabled by adding or removing symlinks from
/etc/nginx/modules-enabled to /etc/nginx/modules-available, potentially
with an eselect module. See bug 967022 for background information.

This commit adds a new eclass variable NGINX_SUPPORT_MODULE_STUBS that
must be turned on to create the directories and add the include into
shipped nginx.conf. Also, the live NGINX version is bumped setting the
new variable.

Bug: https://bugs.gentoo.org/967022
Signed-off-by: Zurab Kvachadze <zurabid2016 <AT> gmail.com>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 eclass/nginx.eclass                   | 21 ++++++++++++++++++
 www-servers/nginx/files/nginx-r5.conf | 40 +++++++++++++++++++++++++++++++++++
 www-servers/nginx/nginx-9999.ebuild   |  5 +++--
 3 files changed, 64 insertions(+), 2 deletions(-)

diff --git a/eclass/nginx.eclass b/eclass/nginx.eclass
index a67da18edef8..05576be94a42 100644
--- a/eclass/nginx.eclass
+++ b/eclass/nginx.eclass
@@ -221,6 +221,14 @@ has "${NGINX_UPDATE_STREAM}" 
"${NGX_UPDATE_STREAMS_LIST[@]}" ||
 # automatically fill the BDEPEND variable with module test dependencies.
 # For details, see _ngx_set_mod_test_depend() function description below.
 
+# @ECLASS_VARIABLE: NGINX_SUPPORT_MODULE_STUBS
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Set this to a non-empty value before calling nginx_src_install() to create
+# /etc/nginx/modules-{available,enabled} and to make the default config load
+# .conf stubs from /etc/nginx/modules-enabled.  See nginx_src_install() for
+# details.
+
 #-----> ebuild setup <-----
 
 # NGINX does not guarantee ABI stability (required by dynamic modules), SLOT is
@@ -850,6 +858,12 @@ nginx_src_install() {
                perl_fix_packlist
        fi
 
+       # If not using modules, do not 'include modules-enabled/*.conf;'. Also, 
just
+       # in case, remove the line if NGINX_SUPPORT_MODULE_STUBS is unset.
+       if use !modules || [[ -z ${NGINX_SUPPORT_MODULE_STUBS} ]]; then
+               sed -i '/^@GENTOO_MODULES_INCLUDE@$/d' 
"${ED}"/etc/nginx/nginx.conf
+       fi
+
        # For the rationale of the following, see nginx-module.eclass.
        if use modules; then
                # Install the headers into /usr/include/nginx.
@@ -906,6 +920,13 @@ nginx_src_install() {
                        variable = BDEPEND
                        includes = ${CATEGORY}/${PN}
                EOF
+
+               if [[ -n ${NGINX_SUPPORT_MODULE_STUBS} ]]; then
+                       keepdir /etc/nginx/modules-{available,enabled}
+
+                       sed -i 's|^@GENTOO_MODULES_INCLUDE@$|include 
modules-enabled/*.conf;|' \
+                               "${ED}"/etc/nginx/nginx.conf
+               fi
        fi
 }
 

diff --git a/www-servers/nginx/files/nginx-r5.conf 
b/www-servers/nginx/files/nginx-r5.conf
new file mode 100644
index 000000000000..5c8aae56f380
--- /dev/null
+++ b/www-servers/nginx/files/nginx-r5.conf
@@ -0,0 +1,40 @@
+user nginx nginx;
+worker_processes auto;
+@GENTOO_MODULES_INCLUDE@
+
+events {
+       # NGINX refuses to start if the 'events' section is not present. Yet,
+       # NGINX does not seem to care whether this section is non-empty.
+}
+
+http {
+       # Maximum hash table size is increased to accommodate for a large
+       # mime.types file that is shipped on Gentoo.
+       types_hash_max_size 4096;
+       include mime.types.nginx;
+
+       sendfile on;
+
+       # Example server. Warning: by default, the /var/www/localhost directory 
is
+       # NOT created; for the following configuration block to work, the
+       # directory must be created manually.
+       server {
+               listen 127.0.0.1;
+               server_name localhost;
+
+               # Substitute the directory below for the one you use.
+               #root /var/www/localhost/htdocs;
+       }
+
+       # SSL server example.
+       #server {
+               #listen 127.0.0.1:443 ssl;
+               #server_name localhost;
+
+               #ssl_certificate /etc/ssl/nginx/nginx.pem;
+               #ssl_certificate_key /etc/ssl/nginx/nginx.key;
+
+               #root /var/www/localhost/htdocs;
+       #}
+
+}

diff --git a/www-servers/nginx/nginx-9999.ebuild 
b/www-servers/nginx/nginx-9999.ebuild
index a2f13adffc00..dd446c87d26c 100644
--- a/www-servers/nginx/nginx-9999.ebuild
+++ b/www-servers/nginx/nginx-9999.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2025 Gentoo Authors
+# Copyright 1999-2026 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
@@ -22,8 +22,9 @@ NGINX_MODULES=(
 NGINX_UPDATE_STREAM=live
 NGINX_TESTS_COMMIT=live
 NGINX_MISC_FILES=(
-       nginx-{r2.logrotate,r2.service,r4.conf,r6.initd,r1.confd,r1.tmpfiles}
+       nginx-{r2.logrotate,r2.service,r5.conf,r6.initd,r1.confd,r1.tmpfiles}
 )
+NGINX_SUPPORT_MODULE_STUBS=1
 
 inherit nginx
 

Reply via email to