diff options
Diffstat (limited to 'hostnix/elmo/system.nix')
| -rw-r--r-- | hostnix/elmo/system.nix | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/hostnix/elmo/system.nix b/hostnix/elmo/system.nix new file mode 100644 index 0000000..8630abc --- /dev/null +++ b/hostnix/elmo/system.nix @@ -0,0 +1,79 @@ +{ config, pkgs, ... }: + +{ + nix.gc = { + automatic = true; + dates = "weekly"; + options = "--delete-older-than 30d"; + }; + nix.settings.auto-optimise-store = true; + + boot.loader.systemd-boot.enable = true; + boot.loader.systemd-boot.configurationLimit = 10; + boot.loader.efi.canTouchEfiVariables = true; + + boot.tmp.useTmpfs = true; + + time.timeZone = "America/New_York"; + + networking.hostName = "elmo"; + networking.domain = "mou.fo"; + + # TODO switch to networkd + networking.networkmanager.enable = true; + + services.avahi = { + enable = true; + nssmdns4 = true; + publish = { + enable = true; + addresses = true; + }; + }; + + # https://nixos.wiki/wiki/Hardware/Apple#Auto_Restart + systemd.services.enable-autorestart = { + description = "Boot after power failure (server mode)"; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + Type = "oneshot"; + }; + # https://superuser.com/a/1051137 + script = "${pkgs.pciutils}/bin/setpci -s 00:1f.0 0xa4.b=0"; + }; + + systemd.services.boot-email = { + description = "Boot email"; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + Type = "oneshot"; + }; + script = '' + echo -e "Subject: ${config.networking.fqdn} restarted\n\n$(date)" | /run/wrappers/bin/sendmail root + ''; + }; + + # https://wiki.archlinux.org/index.php/Systemd/Timers#MAILTO + systemd.services."status-email@" = { + description = "Status email for %i"; + unitConfig = { + # Throttle notifications to twice daily. + StartLimitIntervalSec = "12hr"; + StartLimitBurst = "1"; + }; + serviceConfig = { + Type = "oneshot"; + }; + scriptArgs = "%i"; + script = '' + /run/wrappers/bin/sendmail root <<EOF + From: systemd <root> + Subject: $1 status + Content-Transfer-Encoding: 8bit + Content-Type: text/plain; charset=UTF-8 + + $(systemctl status --full "$1") + EOF + ''; + }; +} |
