162 lines
4 KiB
Nix
162 lines
4 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
let
|
|
contactsBasePath = "${config.xdg.dataHome}/contacts";
|
|
calendarBasePath = "${config.xdg.dataHome}/calendar";
|
|
|
|
personalContactsUuid = "d6abd3ea-3abd-7550-9f24-f06293d36a82";
|
|
|
|
fetchCommand = command:
|
|
if lib.isList command
|
|
then [ "command" ] ++ command
|
|
else [ "command" "sh" "-c" command ];
|
|
|
|
mkDavSection = { type, name, url, username, passwordCommand }: assert builtins.elem type [ "contacts" "calendar" ]; let
|
|
id = "${type}_${name}";
|
|
basePath = {
|
|
"contacts" = contactsBasePath;
|
|
"calendar" = calendarBasePath;
|
|
}.${type};
|
|
in
|
|
{
|
|
"pair ${id}" = {
|
|
a = "${id}_local";
|
|
b = "${id}_remote";
|
|
collections = [ "from a" "from b" ];
|
|
metadata = [ "displayname" ];
|
|
};
|
|
|
|
"storage ${id}_local" = {
|
|
type = "filesystem";
|
|
path = "${basePath}/${name}/";
|
|
fileext = {
|
|
contacts = ".vcf";
|
|
calendar = ".ics";
|
|
}.${type};
|
|
};
|
|
|
|
"storage ${id}_remote" = {
|
|
type = {
|
|
"calendar" = "caldav";
|
|
"contacts" = "carddav";
|
|
}.${type};
|
|
inherit url username;
|
|
"password.fetch" = fetchCommand passwordCommand;
|
|
};
|
|
};
|
|
|
|
mkWebcalSection = { name, url ? null, urlCommand ? null }: assert url == null -> urlCommand != null; {
|
|
"pair calendar_${name}" = {
|
|
a = "calendar_${name}_local";
|
|
b = "calendar_${name}_remote";
|
|
collections = null;
|
|
};
|
|
|
|
"storage calendar_${name}_local" = {
|
|
type = "filesystem";
|
|
path = "${calendarBasePath}/${name}/";
|
|
fileext = ".ics";
|
|
};
|
|
|
|
"storage calendar_${name}_remote" = {
|
|
type = "http";
|
|
} // (if urlCommand != null then {
|
|
"url.fetch" = fetchCommand urlCommand;
|
|
} else {
|
|
inherit url;
|
|
});
|
|
};
|
|
in
|
|
{
|
|
home.packages = with pkgs; [
|
|
khal
|
|
khard
|
|
todoman
|
|
vdirsyncer
|
|
];
|
|
|
|
xdg.configFile = {
|
|
"vdirsyncer/config".text = lib.generators.toINI
|
|
{
|
|
mkKeyValue = k: v: "${k} = ${builtins.toJSON v}";
|
|
}
|
|
({
|
|
general = {
|
|
status_path = "${config.xdg.configHome}/vdirsyncer/status/";
|
|
};
|
|
} // lib.foldl lib.mergeAttrs { } [
|
|
(mkDavSection {
|
|
type = "contacts";
|
|
name = "personal";
|
|
url = "https://dav.sbruder.de/";
|
|
username = "simon@sbruder.de";
|
|
passwordCommand = "pass sbruder.de/mail | head -n 1";
|
|
})
|
|
(mkDavSection {
|
|
type = "calendar";
|
|
name = "personal";
|
|
url = "https://dav.sbruder.de/";
|
|
username = "simon@sbruder.de";
|
|
passwordCommand = "pass sbruder.de/mail | head -n 1";
|
|
})
|
|
]);
|
|
|
|
"khal/config".text = /* toml */ ''
|
|
[default]
|
|
default_calendar = personal
|
|
|
|
[calendars]
|
|
|
|
[[calendar_personal]]
|
|
path = ${calendarBasePath}/personal/*
|
|
type = discover
|
|
|
|
[[contacts_personal]]
|
|
path = ${contactsBasePath}/personal/${personalContactsUuid}/
|
|
type = birthdays
|
|
|
|
[locale]
|
|
timeformat = %H:%M
|
|
dateformat = %Y-%m-%d
|
|
longdateformat = %Y-%m-%d
|
|
datetimeformat = %Y-%m-%d %H:%M
|
|
longdatetimeformat = %Y-%m-%d %H:%M
|
|
'';
|
|
|
|
"khard/khard.conf".text = /* toml */ ''
|
|
[addressbooks]
|
|
[[personal]]
|
|
path = ${contactsBasePath}/personal/${personalContactsUuid}/
|
|
|
|
[general]
|
|
debug = no
|
|
default_action = list
|
|
editor = nvim, -i, NONE
|
|
merge_editor = nvim, -d
|
|
|
|
[contact table]
|
|
display = first_name
|
|
group_by_addressbook = no
|
|
reverse = no
|
|
show_nicknames = yes
|
|
show_uids = no
|
|
sort = last_name
|
|
localize_dates = yes
|
|
preferred_phone_number_type = pref, cell, home
|
|
preferred_email_address_type = pref, home, work
|
|
|
|
[vcard]
|
|
private_objects = Jabber,
|
|
preferred_version = 3.0
|
|
search_in_source_files = no
|
|
skip_unparsable = no
|
|
'';
|
|
|
|
"todoman/config.py".text = /* python */ ''
|
|
path = "${calendarBasePath}/personal/*"
|
|
date_format = "%Y-%m-%d"
|
|
time_format = "%H:%M"
|
|
default_priority = 5
|
|
'';
|
|
};
|
|
}
|