~sumner/nixos-configuration

5b85155a253aa9ffa4f0b649786e3c998e2de087 — Sumner Evans 2 years ago 512a2d6
logrotate: use built-in nginx rotation config
3 files changed, 2 insertions(+), 32 deletions(-)

M host-configurations/mustafar/default.nix
M modules/services/default.nix
D modules/services/logrotate.nix
M host-configurations/mustafar/default.nix => host-configurations/mustafar/default.nix +2 -1
@@ 1,5 1,6 @@
{ lib, pkgs, ... }: with pkgs; let
  sof-firmware = callPackage ./intel-sof-firmware.nix {};
  sof-firmware = callPackage ./intel-sof-firmware.nix { };
  logrotateLib = import ../../lib/logrotate.nix;
in
{
  # Set the hostname

M modules/services/default.nix => modules/services/default.nix +0 -1
@@ 14,7 14,6 @@
    ./healthcheck.nix
    ./isso.nix
    ./journald.nix
    ./logrotate.nix
    ./longview.nix
    ./mumble.nix
    ./nginx.nix

D modules/services/logrotate.nix => modules/services/logrotate.nix +0 -30
@@ 1,30 0,0 @@
{ config, lib, ... }: with lib; let
  mkNginxLogsRotate = pathGlob: keep: {
    inherit keep;
    user = "nginx";
    group = "nginx";
    path = "/var/log/nginx/${pathGlob}.log";
    extraConfig = ''
      size 25M
      missingok
      compress
      delaycompress
      notifempty
      create 0644 nginx nginx
      sharedscripts
      postrotate
        /usr/bin/env kill -USR1 `cat /run/nginx/nginx.pid 2>/dev/null` 2>/dev/null || true
      endscript
    '';
  };
in
mkIf config.services.logrotate.enable {
  services.logrotate = {
    paths = {
      "nginx-sumnerevans-site" = mkIf config.services.nginx.enable (mkNginxLogsRotate "*sumnerevans.com*" 5);
      "nginx-tef" = mkIf config.services.nginx.enable (mkNginxLogsRotate "*the-evans.family*" 2);
      "nginx-matrix" = mkIf config.services.nginx.enable (mkNginxLogsRotate "matrix*" 2);
      "nginx-access-log" = mkIf config.services.nginx.enable (mkNginxLogsRotate "access*" 2);
    };
  };
}