summaryrefslogtreecommitdiff
path: root/hostnix/elmo
diff options
context:
space:
mode:
Diffstat (limited to 'hostnix/elmo')
-rw-r--r--hostnix/elmo/configuration.nix2
-rw-r--r--hostnix/elmo/dyndns.nix1
-rw-r--r--hostnix/elmo/email.nix3
-rw-r--r--hostnix/elmo/system.nix21
4 files changed, 26 insertions, 1 deletions
diff --git a/hostnix/elmo/configuration.nix b/hostnix/elmo/configuration.nix
index 6945fa5..444dc5b 100644
--- a/hostnix/elmo/configuration.nix
+++ b/hostnix/elmo/configuration.nix
@@ -39,6 +39,8 @@
dig
file
gitFull
+ openssl
+ psmisc
tmux
tree
];
diff --git a/hostnix/elmo/dyndns.nix b/hostnix/elmo/dyndns.nix
index aea6776..5bfde47 100644
--- a/hostnix/elmo/dyndns.nix
+++ b/hostnix/elmo/dyndns.nix
@@ -30,6 +30,7 @@
# Defer errors for ~45min, throttle e-mails to ~hourly.
StartLimitIntervalSec = "1hr";
StartLimitBurst = "45";
+ OnFailure = "status-email@%n.service";
};
serviceConfig = {
Type = "oneshot";
diff --git a/hostnix/elmo/email.nix b/hostnix/elmo/email.nix
index 462a3d7..1ea4000 100644
--- a/hostnix/elmo/email.nix
+++ b/hostnix/elmo/email.nix
@@ -17,6 +17,9 @@
systemd.services.postfix-tls-rotate = {
requires = [ "network-online.target" ];
after = [ "network-online.target" ];
+ unitConfig = {
+ OnFailure = "status-email@%n.service";
+ };
serviceConfig = {
Type = "oneshot";
# Not really necessary indirection but interesting to try out. Note we
diff --git a/hostnix/elmo/system.nix b/hostnix/elmo/system.nix
index 4f6ddb7..407ca42 100644
--- a/hostnix/elmo/system.nix
+++ b/hostnix/elmo/system.nix
@@ -34,11 +34,30 @@
# https://nixos.wiki/wiki/Hardware/Apple#Auto_Restart
systemd.services.enable-autorestart = {
description = "Boot after power failure (server mode)";
- wantedBy = [ "default.target" ];
+ wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "oneshot";
};
# https://superuser.com/a/1051137
script = "${pkgs.pciutils}/bin/setpci -s 00:1f.0 0xa4.b=0";
};
+
+ # https://wiki.archlinux.org/index.php/Systemd/Timers#MAILTO
+ systemd.services."status-email@" = {
+ description = "Status email for %i";
+ serviceConfig = {
+ Type = "oneshot";
+ };
+ scriptArgs = "%i";
+ script = ''
+ ${pkgs.mailutils}/bin/mail -s "$1 status" root <<EOF
+ From: systemd <root>
+ Subject: $1 status
+ Content-Transfer-Encoding: 8bit
+ Content-Type: text/plain; charset=UTF-8
+
+ $(systemctl status --full "$1")
+ EOF
+ '';
+ };
}