citadel

My dotfiles, scripts and nix configs
git clone git://jb55.com/citadel
Log | Files | Refs | README | LICENSE

default.nix (630B)


      1 { config, lib, pkgs, ... }:
      2 {
      3   systemd.services."notify-failed@" = {
      4     description = "Job failure notifier";
      5 
      6     serviceConfig.ExecStart = let script = pkgs.writeScript "failure-notifier" ''
      7       #!${pkgs.bash}/bin/bash
      8 
      9       UNIT=$1
     10 
     11       /var/setuid-wrappers/sendmail -t <<ERRMAIL
     12       To: bill@monstercat.com
     13       From: systemd <root@$HOSTNAME>
     14       Subject: $UNIT Failed
     15       Content-Transfer-Encoding: 8bit
     16       Content-Type: text/plain; charset=UTF-8
     17 
     18       $2
     19       $3
     20       $4
     21 
     22       $(systemctl status $UNIT)
     23       ERRMAIL
     24     '';
     25     in "${script} %I 'Hostname: %H' 'Machine ID: %m' 'Boot ID: %b'";
     26 
     27   };
     28 
     29 }