Does Nginx package, in the nixpkgs repos, compiled with mail proxy support

Highly respected community,

I’m trying to setup Nginx as SMTP and IMAP reverse-proxy. But, as specified in the official documentation(Configuring NGINX as a Mail Proxy Server | NGINX Documentation), community version of Nginx has to be compiled with --with-mail --with-mail_ssl_module --with-openssl=[DIR]/openssl-1.1.1

So I’m wondering, if the Nginx package(pkgs.nginx) goes with mail proxy support compiled in?

It seems as if those options are set if withMail in the argset is true:

Which seems to default to false:

So pkgs.nginx.override { withMail = true; } should work.

Just tried it, this way:

environment.systemPackages = with pkgs; [
  nginx.override { withMail = true; }
];

and got:

building Nix...
building the system configuration...
error: The option value `environment.systemPackages.[definition 2-entry 5]' in `/etc/nixos/configuration.nix' is not of type `package'.
(use '--show-trace' to show detailed location information)

You need to use parens:

environment.systemPackages = with pkgs; [
  (nginx.override { withMail = true; })
];

Otherwise, nix would treat nginx.override and { withMail = true; } individual entries in the list.

I prefer let bindings or overlays for this to eventually have a modified package nginxWithMail or something like that.

1 Like

Putting it in systemPackages also won’t work if you run it with the NixOS module, because it doesn’t run nginx from your system path. You’d need to set this option.

1 Like