{ config, lib, pkgs, ... }:

{
  programs.vdirsyncer.enable = true;
  accounts.contact = {
    basePath = ".contact";
    accounts = let
      calendarAccounts = config.accounts.calendar.accounts;
      local = {
        type = "filesystem";
        fileExt = ".vcf";
      };
    in {
      nextcloud = {
        inherit local;
        remote = {
          inherit (calendarAccounts.nextcloud.remote) userName passwordCommand;
          type = "carddav";
          url =
            "https://cloud.xenia.me.uk/remote.php/dav/addressbooks/users/xenia/contacts-1/";
        };
        vdirsyncer = {
          inherit (calendarAccounts.nextcloud.vdirsyncer) enable;
          collections = [ "from a" ];
        };
      };
    };
  };
}