2022-07-07 16:36:00 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2020-11-07 17:13:15 +01:00
|
|
|
let
|
2022-07-07 16:36:00 +02:00
|
|
|
contactsBasePath = "${config.xdg.dataHome}/contacts";
|
|
|
|
calendarBasePath = "${config.xdg.dataHome}/calendar";
|
|
|
|
|
2022-07-10 12:08:26 +02:00
|
|
|
personalCalendarUuid = "bda1b0cb-994c-366c-e1fe-de646c26e337";
|
2022-07-07 16:36:00 +02:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
};
|
2022-07-07 16:36:38 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
});
|
|
|
|
};
|
2020-11-07 17:13:15 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
home.packages = with pkgs; [
|
2022-07-07 18:03:50 +02:00
|
|
|
unstable.khal
|
2020-11-07 17:13:15 +01:00
|
|
|
khard
|
|
|
|
vdirsyncer
|
|
|
|
];
|
|
|
|
|
|
|
|
xdg.configFile = {
|
2022-07-07 16:36:00 +02:00
|
|
|
"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";
|
|
|
|
})
|
2022-07-07 16:36:38 +02:00
|
|
|
(mkWebcalSection {
|
|
|
|
name = "grocy";
|
|
|
|
urlCommand = [ "pass" "sbruder.de/grocy/calendar" ];
|
|
|
|
})
|
2022-08-08 11:47:05 +02:00
|
|
|
(mkWebcalSection {
|
|
|
|
name = "son";
|
|
|
|
url = "https://calendar.google.com/calendar/ical/4g9n5okqt5f079dedfeu5mgils%40group.calendar.google.com/public/basic.ics";
|
|
|
|
})
|
2022-07-07 16:36:00 +02:00
|
|
|
]);
|
2020-11-07 17:13:15 +01:00
|
|
|
|
2021-08-05 13:23:07 +02:00
|
|
|
"khal/config".text = /* toml */ ''
|
2022-07-10 12:08:26 +02:00
|
|
|
[default]
|
|
|
|
default_calendar = ${personalCalendarUuid}
|
|
|
|
|
2020-11-07 17:13:15 +01:00
|
|
|
[calendars]
|
|
|
|
|
2022-07-07 16:36:00 +02:00
|
|
|
[[calendar_personal]]
|
|
|
|
path = ${calendarBasePath}/personal/*
|
2020-11-07 17:13:15 +01:00
|
|
|
type = discover
|
|
|
|
|
2022-07-07 16:36:00 +02:00
|
|
|
[[contacts_personal]]
|
|
|
|
path = ${contactsBasePath}/personal/${personalContactsUuid}/
|
2020-11-07 17:13:15 +01:00
|
|
|
type = birthdays
|
|
|
|
|
2022-07-07 16:36:38 +02:00
|
|
|
[[calendar_grocy]]
|
|
|
|
path = ${calendarBasePath}/grocy/
|
|
|
|
|
2022-08-08 11:47:05 +02:00
|
|
|
[[calendar_son]]
|
|
|
|
path = ${calendarBasePath}/son/
|
|
|
|
|
2020-11-07 17:13:15 +01:00
|
|
|
[locale]
|
|
|
|
timeformat = %H:%M
|
|
|
|
dateformat = %Y-%m-%d
|
|
|
|
longdateformat = %Y-%m-%d
|
|
|
|
datetimeformat = %Y-%m-%d %H:%M
|
|
|
|
longdatetimeformat = %Y-%m-%d %H:%M
|
|
|
|
'';
|
|
|
|
|
2021-08-05 13:23:07 +02:00
|
|
|
"khard/khard.conf".text = /* toml */ ''
|
2020-11-07 17:13:15 +01:00
|
|
|
[addressbooks]
|
|
|
|
[[personal]]
|
2022-07-07 16:36:00 +02:00
|
|
|
path = ${contactsBasePath}/personal/${personalContactsUuid}/
|
2020-11-07 17:13:15 +01:00
|
|
|
|
|
|
|
[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
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|