anchor.diff:      # not connected to a tty (it is connected to the journal):
       #   wall: cannot get tty name: Inappropriate ioctl for device
       # The message still gets through.
  -    #
  -    # TODO: apcupsd calls "mail" on powerfail etc. events, how should we
  -    # handle that? A configurable mail package or let the event logic be
  -    # configured from nix expressions?
       systemd.services.apcupsd = {
         description = "UPS daemon";
         wantedBy = [ "multi-user.target" ];
  
positive.code: 
  with pkgs.lib;
  
  let cfg = config.services.apcupsd;
      configFile = pkgs.writeText "apcupsd.conf" ''
        ## apcupsd.conf v1.1 ##
        # apcupsd complains if the first line is not like above.
        ${cfg.configText}
      '';
  in
  
  {
  
negative.code:   ###### implementation
  
    config = mkIf cfg.enable {
  
      assertions = [ {
        assertion = let hooknames = builtins.attrNames cfg.hooks; in all (x: elem x eventList) hooknames;
        message = ''
          One (or more) attribute names in services.apcupsd.hooks are invalid.
          Current attribute names: ${toString (builtins.attrNames cfg.hooks)}
          Valid attribute names  : ${toString eventList}
        '';
      } ];
  
      # Give users access to the "apcaccess" tool
      environment.systemPackages = [ pkgs.apcupsd ];
  