citadel

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

default.nix (1309B)


      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       /run/wrappers/bin/sendmail -f bill@monstercat.com -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   # todo: abstract
     30   systemd.user.services."notify-failed-user@" = {
     31     description = "Job failure notifier";
     32 
     33     serviceConfig.ExecStart = let script = pkgs.writeScript "failure-notifier" ''
     34       #!${pkgs.bash}/bin/bash
     35 
     36       UNIT=$1
     37 
     38       /run/wrappers/bin/sendmail -f bill@monstercat.com -t <<ERRMAIL
     39       To: bill@monstercat.com
     40       From: systemd <root@$HOSTNAME>
     41       Subject: user $UNIT Failed
     42       Content-Transfer-Encoding: 8bit
     43       Content-Type: text/plain; charset=UTF-8
     44 
     45       $2
     46       $3
     47       $4
     48 
     49       $(systemctl --user status $UNIT)
     50       ERRMAIL
     51     '';
     52     in "${script} %I 'Hostname: %H' 'Machine ID: %m' 'Boot ID: %b'";
     53 
     54   };
     55 
     56 }