mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
logrotate: move mail dependency from package to service
having pkgs.logrotate depend on mailutils brings in quite a bit of dependencies through mailutil itself and recursive dependency to guile when most people do not need it. Remove mailutils dependency from the package, and conditionally add it to the service if the user specify the mail option either at top level or in a path Fixes #162001
This commit is contained in:
parent
29ac6896e4
commit
b457d917dc
3 changed files with 32 additions and 18 deletions
|
@ -97,12 +97,18 @@ let
|
|||
'';
|
||||
|
||||
paths = sortProperties (attrValues (filterAttrs (_: pathOpts: pathOpts.enable) cfg.paths));
|
||||
configFile = pkgs.writeText "logrotate.conf" (
|
||||
concatStringsSep "\n" (
|
||||
configText = concatStringsSep "\n" (
|
||||
[ "missingok" "notifempty" cfg.extraConfig ] ++ (map mkConf paths)
|
||||
)
|
||||
);
|
||||
);
|
||||
configFile = pkgs.writeText "logrotate.conf" configText;
|
||||
|
||||
mailOption =
|
||||
# add mail option to service if a mail is requested in config
|
||||
# this ugly match will be replaced by cleaner attribute check in
|
||||
# the near future
|
||||
if builtins.match "(.*[[:space:]])?mail[[:space:]].*" configText != null
|
||||
then "--mail=${pkgs.mailutils}/bin/mail"
|
||||
else "";
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
|
@ -172,7 +178,7 @@ in
|
|||
serviceConfig = {
|
||||
Restart = "no";
|
||||
User = "root";
|
||||
ExecStart = "${pkgs.logrotate}/sbin/logrotate ${configFile}";
|
||||
ExecStart = "${pkgs.logrotate}/sbin/logrotate ${mailOption} ${configFile}";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue