diff options
author | Dominique Martinet <asmadeus@codewreck.org> | 2022-02-27 19:06:44 +0900 |
---|---|---|
committer | Dominique Martinet <asmadeus@codewreck.org> | 2022-04-01 07:09:24 +0900 |
commit | b457d917dcfa6d73fdb7b9317440ff5fb5ee4b8b (patch) | |
tree | 547b0de7bd0adf476deaa8cc8427e440ca6d1f6b /nixos/tests/logrotate.nix | |
parent | 29ac6896e4c681b4c29896d6cfd8aeddb56c7887 (diff) |
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
Diffstat (limited to 'nixos/tests/logrotate.nix')
-rw-r--r-- | nixos/tests/logrotate.nix | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/nixos/tests/logrotate.nix b/nixos/tests/logrotate.nix index 7e3046c94272c..85923465593a9 100644 --- a/nixos/tests/logrotate.nix +++ b/nixos/tests/logrotate.nix @@ -1,26 +1,33 @@ # Test logrotate service works and is enabled by default -import ./make-test-python.nix ({ pkgs, ...} : rec { +import ./make-test-python.nix ({ pkgs, ... }: rec { name = "logrotate"; meta = with pkgs.lib.maintainers; { maintainers = [ martinetd ]; }; - # default machine - nodes.machine = { ... }: { + nodes = { + defaultMachine = { ... }: { }; + machine = { config, ... }: { + services.logrotate.paths = { + # using mail somewhere should add --mail to logrotate invokation + sendmail = { + extraConfig = "mail user@domain.tld"; + }; + }; + }; }; testScript = '' with subtest("whether logrotate works"): - machine.succeed( - # we must rotate once first to create logrotate stamp - "systemctl start logrotate.service") + # we must rotate once first to create logrotate stamp + defaultMachine.succeed("systemctl start logrotate.service") # we need to wait for console text once here to # clear console buffer up to this point for next wait - machine.wait_for_console_text('logrotate.service: Deactivated successfully') + defaultMachine.wait_for_console_text('logrotate.service: Deactivated successfully') - machine.succeed( + defaultMachine.succeed( # wtmp is present in default config. "rm -f /var/log/wtmp*", # we need to give it at least 1MB @@ -28,10 +35,14 @@ import ./make-test-python.nix ({ pkgs, ...} : rec { # move into the future and check rotation. "date -s 'now + 1 month + 1 day'") - machine.wait_for_console_text('logrotate.service: Deactivated successfully') - machine.succeed( + defaultMachine.wait_for_console_text('logrotate.service: Deactivated successfully') + defaultMachine.succeed( # check rotate worked "[ -e /var/log/wtmp.1 ]", ) + with subtest("default config does not have mail"): + defaultMachine.fail("systemctl cat logrotate.service | grep -- --mail") + with subtest("using mails adds mail option"): + machine.succeed("systemctl cat logrotate.service | grep -- --mail") ''; }) |