Add vdirsyncer
This commit is contained in:
parent
d23de6e138
commit
7ae83a57c6
2 changed files with 155 additions and 0 deletions
|
|
@ -29,6 +29,7 @@
|
|||
./terraform.nix
|
||||
./tmux.nix
|
||||
./tor-browser.nix
|
||||
./vdirsyncer.nix
|
||||
];
|
||||
|
||||
programs.nix-index.enable = true;
|
||||
|
|
|
|||
154
home-manager/modules/vdirsyncer.nix
Normal file
154
home-manager/modules/vdirsyncer.nix
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
let
|
||||
contactsBasePath = "${config.xdg.dataHome}/contacts";
|
||||
calendarBasePath = "${config.xdg.dataHome}/calendar";
|
||||
|
||||
personalCalendarUuid = "e641fa49-9205-497f-a3bf-c7ef901d32bb";
|
||||
personalContactsUuid = "7aa85437-9f25-456a-be85-3bc68c5d573e";
|
||||
|
||||
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
|
||||
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://cal.jalr.de/";
|
||||
username = "mail@jalr.de";
|
||||
passwordCommand = "pass private/self-hosted/radicale | head -n 1";
|
||||
})
|
||||
(mkDavSection {
|
||||
type = "calendar";
|
||||
name = "personal";
|
||||
url = "https://cal.jalr.de/";
|
||||
username = "mail@jalr.de";
|
||||
passwordCommand = "pass private/self-hosted/radicale | head -n 1";
|
||||
})
|
||||
]);
|
||||
|
||||
"khal/config".text = /* toml */ ''
|
||||
[default]
|
||||
default_calendar = ${personalCalendarUuid}
|
||||
|
||||
[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
|
||||
'';
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue