anchor.diff:          '';
         };
   
  -      label = mkOption {
  -        type = types.str;
  -        default = "nixos";
  -        description = ''
  -          Specifies the label for archives created by Tarsnap. The
  -          full name will be
  -          <literal>label-$(date+"%Y%m%d%H%M%S")</literal>. For
  -          example, by default your backups will look similar to
  -          <literal>nixos-20140301011501</literal>.
  +      keyfile = mkOption {
  +        type = types.path;
  +        default = "/root/tarsnap.key";
  +        description = ''
  +          Path to the keyfile which identifies the machine
  +          associated with your Tarsnap account. This file can
  +          be created using the
  +          <literal>tarsnap-keygen</literal> utility, and
  +          providing your Tarsnap login credentials.
           '';
         };
   
  
positive.code: 
    optionalNullStr = e: v: if e == null then "" else v;
  
    configFile = pkgs.writeText "tarsnap.conf" ''
      cachedir ${cfg.cachedir}
      keyfile  ${cfg.keyfile}
      ${optionalString cfg.nodump "nodump"}
      ${optionalString cfg.printStats "print-stats"}
      ${optionalNullStr cfg.checkpointBytes "checkpoint-bytes "+cfg.checkpointBytes}
  
negative.code: 
    config = mkIf cfg.enable {
      assertions =
        (mapAttrsToList (name: cfg:
          { assertion = cfg.directories != [];
            message = "Must specify directories for Tarsnap to back up";
          }) cfg.config) ++
        (mapAttrsToList (name: cfg:
          { assertion = cfg.lowmem -> !cfg.verylowmem && (cfg.verylowmem -> !cfg.lowmem);
            message = "You cannot set both lowmem and verylowmem";
          }) cfg.config);
  
      systemd.services."tarsnap@" = {
        description = "Tarsnap Backup of '%i'";
        requires    = [ "network.target" ];
  
        path = [ pkgs.tarsnap pkgs.coreutils ];
        scriptArgs = "%i";
        script = ''
          mkdir -p -m 0755 $(dirname ${cfg.cachedir})
          mkdir -p -m 0600 ${cfg.cachedir}
          DIRS=`cat /etc/tarsnap/$1.dirs`
          exec tarsnap --configfile /etc/tarsnap/$1.conf -c -f $1-$(date +"%Y%m%d%H%M%S") $DIRS
        '';
      };
  
      services.cron.systemCronJobs = mapAttrsToList (name: cfg:
        "${cfg.period} root ${config.systemd.package}/bin/systemctl start tarsnap@${name}"
      ) cfg.config;
  
      environment.etc =
        (mapAttrs' (name: cfg: nameValuePair "tarsnap/${name}.conf"
          { text = configFile cfg;
          }) cfg.config) //
        (mapAttrs' (name: cfg: nameValuePair "tarsnap/${name}.dirs"
          { text = concatStringsSep " " cfg.directories;
          }) cfg.config);
  
      environment.systemPackages = [ pkgs.tarsnap ];
    };
  