[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Improving how NGINX modules are used and built
From: |
mirai |
Subject: |
Improving how NGINX modules are used and built |
Date: |
Thu, 29 Dec 2022 02:10:27 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 |
Consider the following nginx-configuration modules field snippet from Guix docs:
--8<---------------cut here---------------start------------->8---
(modules
(list
(file-append nginx-accept-language-module "\
/etc/nginx/modules/ngx_http_accept_language_module.so")
(file-append nginx-lua-module "\
/etc/nginx/modules/ngx_http_lua_module.so")))
--8<---------------cut here---------------end--------------->8---
It is unclear at all how an arbitrary nginx module should be added given that
one needs to append the package object with a path to the modules .so file.
This .so name can only be found by listing the files from the package object
which adds further obscurity to what should have been:
--8<---------------cut here---------------start------------->8---
(modules
(list nginx-accept-language-module nginx-lua-module))
--8<---------------cut here---------------end--------------->8---
An oddity of how nginx modules are packaged in guix is that they all place
the .so file under /etc/nginx/modules which is an odd directory to place
library object files.
Compared against other distributions, they tend to place the .so files under
/usr/lib64/nginx
and a .conf file under /usr/share/nginx/modules that contains
--8<---------------cut here---------------start------------->8---
load_module "/usr/lib64/nginx/modules/ngx_foo_module.so";
--8<---------------cut here---------------end--------------->8---
My guess is that the intention behind
(file-append nginx-foo-module "/etc/nginx/modules/ngx_foo.so") is that
it was supposed to replicate the .conf behavior but inadvertently ended up being
used as a place for .so files.
Looking at how network-manager-configuration handles its vpn-plugins field, it
seems doable
that a similar approach can be used here.
The existing nginx-modules should be changed to install their .so files under
lib{64}/nginx
instead and they should drop a etc/nginx/modules/foo_module.conf file
responsible for loading
the module from the .so file. Including modules through a .conf should be
preferred as
there's no guarantee that a module is a .so file or that it is always a
_single_ .so file but in general this file should typically be a one-line .conf
file containing:
--8<---------------cut here---------------start------------->8---
load_module
"/gnu/store/......nginx-foo-module/usr/lib64/nginx/ngx_foo_module.so";
--8<---------------cut here---------------end--------------->8---
And nginx-configuration should serialize the modules field as a series of lines
including
the module .conf files, that is:
--8<---------------cut here---------------start------------->8---
include
"/gnu/store/......nginx-foo-module/etc/nginx/modules/ngx_foo_module.conf";
include
"/gnu/store/......nginx-bar-module/etc/nginx/modules/ngx_bar_module.conf";
...
--8<---------------cut here---------------end--------------->8---
(note: a directory union could be used here as an alternative)
On a related note, given how nginx-modules are expected to be built and linked
against the
same nginx build, a new nginx-build-system for nginx modules could be
considered as the few
existing nginx modules in guix are for the most part a copy-paste of each other
with some
modifications here-and-there.
Thoughts?
Regards,
Bruno
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Improving how NGINX modules are used and built,
mirai <=