anchor.diff:  let
   
     cfg = config.services.smartd;
  +
  +  smartdMail = pkgs.writeScript "smartdmail.sh" ''
  +    #! /bin/sh
  +    TMPNAM=/tmp/smartd-message.$$.tmp
  +    if test -n "$SMARTD_ADDRESS"; then
  +      echo  >"$TMPNAM" "From: smartd <root>"
  +      echo >>"$TMPNAM" 'To: undisclosed-recipients:;'
  +      echo >>"$TMPNAM" "Subject: $SMARTD_SUBJECT"
  +      echo >>"$TMPNAM"
  +      echo >>"$TMPNAM" "Failure on $SMARTD_DEVICESTRING: $SMARTD_FAILTYPE"
  +      echo >>"$TMPNAM"
  +      cat  >>"$TMPNAM"
  +      ${pkgs.smartmontools}/sbin/smartctl >>"$TMPNAM" -a -d "$SMARTD_DEVICETYPE" "$SMARTD_DEVICE"
  +      /var/setuid-wrappers/sendmail  <"$TMPNAM" -f "$SENDER" -i "$SMARTD_ADDRESS"
  +    fi
  +  '';
  +
  +  smartdConf = pkgs.writeText "smartd.conf" (concatMapStrings (device:
  +    ''
  +      ${device} -m root -M exec ${smartdMail}
  +    ''
  +    ) cfg.devices);
  +
  +  smartdFlags = if (cfg.devices == []) then "" else "--configfile=${smartdConf}";
   
   in
   
  
positive.code:         type = types.bool;
          example = "true";
          description = ''
            Run smartd from the smartmontools package.
          '';
        };
  
      };
  
    };
  
negative.code: 
          daemonType = "daemon";
  
          exec = "${pkgs.smartmontools}/sbin/smartd --pidfile=/var/run/smartd.pid ${smartdFlags}";
        };
  
    };
  