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
This commit is contained in:
Lara
2021-09-15 09:57:18 +02:00
committed by Yuka
parent 0e848f7b12
commit fe034d33be
+49
View File
@@ -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
<link xlink:href="https://linux.die.net/man/8/logrotate"/> 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.