I am trying to change the MIME types definition in NixOS nginx module. It is using pkgs.mailcap, so as a first option, I have added the following overlay:
It works, but nginx module is not the only user of mailcap and my system is trying to recompile Go. I don’t want that. Ideally, I would like to override pkgs in NixOS nginx module definition.
Is there a possibility to use .override or the overlay system with NixOS modules?
nginx package does not use mailcap. Only the module uses mailcap. That’s why I am looking to have an overlay for the module. Also, mailcap is just a call to fetchzip not a derivation calling fetchzip, but I’ll try your suggestion later nonetheless.
Following your second suggestion, I have added this:
Ideally, there should be a way to configure this. Importing from mailcap may be desirable in most cases. But it still seems weird to have to go through these hoops.
Something like services.nginx.useMailcapMIMETypes = true; as a default, then make the offending lines:
commonHttpConfig = ''
# The mime type definitions included with nginx are very incomplete, so
# we use a list of mime types from the mailcap package, which is also
# used by most other Linux distributions by default.
${lib.optionalString cfg.useMailcapMIMETypes "include ${pkgs.mailcap}/etc/nginx/mime.types;"}
include ${cfg.package}/conf/fastcgi.conf;
include ${cfg.package}/conf/uwsgi_params;
'';
also, I feel like it would makes sense to have an option for extraMIMETypes
include ${cfg.package}/conf/uwsgi_params;
${cfg.extraMIMETypes}
'';
In most cases, you need to include some MIME types. The choice is more
between the builtin list from nginx (which is easier to override since
it’s part of nginx package) and the list from mailcap (which is more
complete).
I think the most sensible change would be to have something like that:
commonHttpConfig = ''
include ${cfg.package}/conf/mime.types;
include ${cfg.package}/conf/fastcgi.conf;
include ${cfg.package}/conf/uwsgi_params;
'';
By default, content of mime.types would be from pkgs.mailcap, but
you could have extraMIMETypes to add at the end of the file or ability
to override its content entirely.