Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nginx: expose list of additional modules #53897

Merged
merged 1 commit into from Jan 31, 2019

Conversation

vincentbernat
Copy link
Member

Motivation for this change

Currently, it seems there is no easy way to override package to add
modules. For example, if we want to add the ipscrub module, we can
do:

pkgs.nginxStable.override {
  modules = [ pkgs.nginxModules.ipscrub ];
};

But, then, we loose rtmp, dav and moreheaders which are defined
in all-packages.nix. With this modification, we can now do:

pkgs.nginxStable.override {
  modules = pkg.nginxStable.passthru.modules ++ [ pkgs.nginxModules.ipscrub ];
};

I have been suggested this on IRC by @cleverca22. He told me to put that in meta, but I didn't find another example of use of passthru in meta while there are several examples of using passthru outside of meta. Tested through nix repl with:

:l <nixpkgs>
myNginx = pkgs.nginxStable.override { modules = pkgs.nginxStable.passthru.modules ++ [ pkgs.nginxModules.ipscrub ]; }
:b myNginx

Then /nix/store/.../bin/nginx -V shows:

nginx version: nginx/1.14.2
built by gcc 7.4.0 (GCC)
built with OpenSSL 1.0.2q  20 Nov 2018
TLS SNI support enabled
configure arguments: --prefix=/nix/store/11pr5fhax5gfslhirlcr6zvylk5090wy-nginx-1.14.2 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module --with-threads --with-pcre-jit --with-stream --with-stream_geoip_module --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_image_filter_module --with-file-aio --add-module=/nix/store/4w2zbpv9ihl36kbpp6w5d1x33gp5ivfh-source --add-module=/nix/store/c1d0qwva4ncx3473pl336q3fbjs5qslr-source --add-module=/nix/store/jsqrk045m09i136mgcfjfai8i05nq14c-source --add-module=/nix/store/14a8h4xrv62l0b7njnq1jgka7ci6biv6-source/ipscrub
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Currently, it seems there is no easy way to override package to add
modules. For example, if we want to add the `ipscrub` module, we can
do:

    pkgs.nginxStable.override {
      modules = [ pkgs.nginxModules.ipscrub ];
    };

But, then, we loose `rtmp`, `dav` and `moreheaders` which are defined
in `all-packages.nix`. With this modification, we can now do:

    pkgs.nginxStable.override {
      modules = pkg.nginxStable.passthru.modules ++ [ pkgs.nginxModules.ipscrub ];
    };
@danbst
Copy link
Contributor

danbst commented Jan 31, 2019

Oh, this is hack. OTOH, it is backwards compatible hack.

Better solution would be to introduce defaultModules, which is set in all-packages.nix, and leave modules for any user overrides. However in this case we have to add release notes, that users may suddenly get a few more modules (which may, btw, duplicate already defined. Curious, does nginx handle duplicate modules correctly?)

But, even in that scenario, having modules passthru shouldn't harm.

@danbst
Copy link
Contributor

danbst commented Jan 31, 2019

pkg.nginxStable.passthru.modules ++ [ pkgs.nginxModules.ipscrub ];

btw, you don't need that .passthru word. pkg.nginxStable.modules should work as well.

@danbst danbst merged commit 33802e9 into NixOS:master Jan 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants