From f88c4455c764f6a8fed20d2e8ac3dadd86a1ce8c Mon Sep 17 00:00:00 2001 From: Igor Pashev Date: Thu, 22 Dec 2016 15:29:16 +0300 Subject: nginx: configure logrotate --- modules/apps/nginx.nix | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'modules/apps') diff --git a/modules/apps/nginx.nix b/modules/apps/nginx.nix index d7b3c13..1b10145 100644 --- a/modules/apps/nginx.nix +++ b/modules/apps/nginx.nix @@ -6,8 +6,8 @@ let elem filter isBool ; inherit (lib) - concatMapStrings concatStringsSep filterAttrs mapAttrsToList mkEnableOption - mkIf mkOption ; + concatMapStrings concatStringsSep filterAttrs mapAttrsToList mkDefault + mkEnableOption mkIf mkOption ; inherit (lib.types) attrsOf bool either enum int lines nullOr path str submodule ; @@ -149,6 +149,20 @@ in { nixsap.system.users.daemons = mkIf enabled [ cfg.user ]; + nixsap.apps.logrotate.conf.nginx = mkIf enabled { + files = "${cfg.logDir}/*.log"; + directives = { + delaycompress = mkDefault true; + missingok = mkDefault true; + notifempty = mkDefault true; + rotate = mkDefault 14; + sharedscripts = true; + daily = mkDefault true; + create = mkDefault "0640 ${cfg.user} ${cfg.user}"; + postrotate = pkgs.writeBashScript "logrotate-nginx-postrotate" "systemctl kill -s SIGUSR1 nginx.service"; + }; + }; + systemd.services.nginx = mkIf enabled { description = "web/proxy server"; wants = [ "keys.target" ]; -- cgit v1.2.3