From fe034d33be5ccf3efc850a6021a1ab41cf5831d1 Mon Sep 17 00:00:00 2001 From: Lara Date: Sat, 4 Sep 2021 22:42:26 +0200 Subject: [PATCH] nixos/gitlab: Enable roation of log files This commit enables a logrotate service for gitlab using the default values from omnibus. [1] [1] https://gitlab.com/gitlab-org/omnibus-gitlab/-/blob/master/files/gitlab-cookbooks/gitlab/attributes/default.rb#L754 Resolves #136723 --- nixos/modules/services/misc/gitlab.nix | 49 ++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/nixos/modules/services/misc/gitlab.nix b/nixos/modules/services/misc/gitlab.nix index 805deeee0c04..c1a1491b3cee 100644 --- a/nixos/modules/services/misc/gitlab.nix +++ b/nixos/modules/services/misc/gitlab.nix @@ -821,6 +821,40 @@ in { ''; }; + logrotate = { + enable = mkOption { + type = types.bool; + default = true; + description = '' + Enable rotation of log files. + ''; + }; + + frequency = mkOption { + type = types.str; + default = "daily"; + description = "How often to rotate the logs."; + }; + + keep = mkOption { + type = types.int; + default = 30; + description = "How many rotations to keep."; + }; + + extraConfig = mkOption { + type = types.lines; + default = '' + copytruncate + compress + ''; + description = '' + Extra logrotate config options for this path. Refer to + for details. + ''; + }; + }; + extraConfig = mkOption { type = types.attrs; default = {}; @@ -932,6 +966,21 @@ in { ensureUsers = singleton { name = cfg.databaseUsername; }; }; + # Enable rotation of log files + services.logrotate = { + enable = cfg.logrotate.enable; + paths = { + gitlab = { + path = "${cfg.statePath}/log/*.log"; + user = cfg.user; + group = cfg.group; + frequency = cfg.logrotate.frequency; + keep = cfg.logrotate.keep; + extraConfig = cfg.logrotate.extraConfig; + }; + }; + }; + # The postgresql module doesn't currently support concepts like # objects owners and extensions; for now we tack on what's needed # here.