blob: bde99d7cea08bea60bb97ca01fed4d6f92d93377 (
plain)
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
|
{
inputs,
config,
...
}:
{
system.autoUpgrade = {
enable = true;
flake = inputs.self.outPath;
flags = [
"--update-input"
"nixpkgs"
"-L"
];
dates = "Sat *-*-* 06:00:00";
randomizedDelaySec = "45min";
allowReboot = true;
};
systemd.services."server-monitor" =
let
dependencies = [ "network-online.target" ];
in
{
wantedBy = [ "multi-user.target" ];
wants = dependencies;
after = dependencies;
serviceConfig.Type = "oneshot";
script = ''
ACTION="restarted"
# If a system has been up for *at least* 90 seconds, make the assumption
# that the system's configuration was rebuilt and activated.
if [ "$(cat /proc/uptime | cut -f1 -d.)" -gt 90 ]; then
ACTION="activated a new configuration"
fi
/run/current-system/sw/bin/pushover -t "${config.networking.hostName}" \
"Server $ACTION on $(date '+%a, %b %d at %T %p %Z')."
'';
};
}
|