-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
72 lines (63 loc) · 1.89 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
{
description = "Logwatch for NixOS";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
packages = rec {
default = logwatch;
logwatch = pkgs.callPackage ./packages/logwatch.nix { };
nix-gc-script = pkgs.callPackage ./packages/logwatch-scripts/nix-gc.nix { };
nixos-upgrade-script = pkgs.callPackage ./packages/logwatch-scripts/nixos-upgrade.nix { };
};
checks.default = pkgs.nixosTest {
name = "logwatch-module-test";
nodes.server =
{ ... }:
{
imports = [ self.nixosModules.logwatch ];
environment.systemPackages = [ pkgs.mailutils ];
services = {
logwatch.enable = true;
postfix.enable = true;
};
};
testScript = ''
import time
start_all()
server.wait_for_unit("default.target")
# Force restart of logwatch so it sends a mail
server.systemctl("restart logwatch")
# VMs on CI runners can be kind of slow, delay here
time.sleep(3)
# Get all mails for root and check if the expected subject is there
mail = server.succeed("mail -p")
print(mail)
if "Subject: Logwatch for server" not in mail:
raise
if "Logwatch ${self.packages.${system}.logwatch.version}" not in mail:
raise
'';
};
formatter = pkgs.nixfmt-rfc-style;
}
)
// {
nixosModules = {
logwatch = import ./modules/logwatch.nix;
};
};
}