How to remove the default nginx logrotate config provided by the nginx NixOS module

The Nginx NixOS module provides a default logrotate config, as seen here: nixpkgs/default.nix at 891ed931cbcf7bd2b0c54673a9d87708d54a122b · NixOS/nixpkgs · GitHub

I want to completely disable this config, because I do not want any log rotation for Nginx. How would I go about that? These are possible solutions, neither of which is good:

Completely turn off logrotate

services.logrotate.enable = false;

This is what I currently do, but then I cannot use logrotate at all on the whole server, and if I accidentally turn on logrotate, the Nginx logs will get rotated.

Try to override the config

{ config, pkgs, ... }:
{
    services.logrotate.settings =
        builtins.removeAttrs config.services.logrotate.settings [ "nginx" ];
}

This results in an infinite loop.

Override with additional logrotate options

services.logrotate.settings.nginx.minsize = "1000000G";

This is ugly, possibly brittle, and I’m not sure if this is really fool proof and if I understand the interactions of different logrotate options correctly.

1 Like

You’re looking for services.logrotate.settings.nginx.enable = false;.

4 Likes

Thank you, this is exactly what I was looking for!