nix-config/modules/home-manager/dav/default.nix

196 lines
5.7 KiB
Nix

{ config, pkgs, ... }:
let
calendars = "${config.home.homeDirectory}/Calendars";
contacts = "${config.home.homeDirectory}/Contacts";
addressbook = "${config.home.homeDirectory}/.abook/addressbook";
davsync = pkgs.callPackage ./davsync.nix {
inherit config pkgs contacts addressbook;
};
pass = "${pkgs.pass}/bin/pass";
tokens = "${config.home.homeDirectory}/.vdirsyncer/tokens/";
in
{
home.packages = with pkgs; [ dav-sync vdirsyncer khal khard abook ];
home.file.".config/vdirsyncer/config".text = ''
[general]
status_path = "${config.home.homeDirectory}/.vdirsyncer/status/"
#############
# nextcloud #
#############
## calendar
[pair nextcloud_calendar]
a = "nextcloud_calendar_local"
b = "nextcloud_calendar_remote"
collections = ["personal", "contact_birthdays", "events"]
metadata = ["color"]
[storage nextcloud_calendar_local]
type = "filesystem"
path = "${calendars}/nextcloud/"
fileext = ".ics"
[storage nextcloud_calendar_remote]
type = "caldav"
url = "https://nextcloud.monotremata.xyz/"
username = "rilla"
password.fetch = ["command", "${pass}", "narwhal/nextcloud.monotremata.xyz/rilla"]
## contacts
[pair nextcloud_contacts]
a = "nextcloud_contacts_local"
b = "nextcloud_contacts_remote"
collections = ["contacts"]
[storage nextcloud_contacts_local]
type = "filesystem"
path = "${contacts}/nextcloud/"
fileext = ".vcf"
[storage nextcloud_contacts_remote]
type = "carddav"
url = "https://nextcloud.monotremata.xyz/"
username = "rilla"
password.fetch = ["command", "${pass}", "narwhal/nextcloud.monotremata.xyz/rilla"]
##########
# google #
##########
## calendar
[pair google_calendar_sync]
a = "google_calendar_remote"
b = "google_calendar_local"
collections = [["gcal", "r.illa.pujagut@gmail.com", "r.illa.pujagut@gmail.com"]]
[storage google_calendar_local]
type = "filesystem"
path = "${calendars}/google/"
fileext = ".ics"
[storage google_calendar_remote]
type = "google_calendar"
token_file = "${tokens}/goole_calendar"
client_id.fetch = ["command", "${pass}", "google.com/vdirsyncer/client_id"]
client_secret.fetch = ["command", "${pass}", "google.com/vdirsyncer/client_secret"]
## contacts
[pair google_contacts]
a = "google_contacts_local"
b = "google_contacts_remote"
collections = [["gcontacts", "default", "default"]]
[storage google_contacts_local]
type = "filesystem"
path = "${contacts}/google/"
fileext = ".vcf"
[storage google_contacts_remote]
type = "google_contacts"
token_file = "${tokens}/google_contacts"
client_id.fetch = ["command", "${pass}", "google.com/vdirsyncer/client_id"]
client_secret.fetch = ["command", "${pass}", "google.com/vdirsyncer/client_secret"]
'';
home.file.".config/khal/config".text = ''
[calendars]
[[default]]
path = ${calendars}/nextcloud/personal/
color = dark green
[[birthdays]]
path = ${calendars}/nextcloud/contact_birthdays/
color = dark green
[[google]]
path = ${calendars}/google/r.illa.pujagut@gmail.com/
color = dark blue
[[events]]
path = ${calendars}/nextcloud/events
color = brown
# supported colors:
# black, white, brown, yellow, dark gray, dark green, dark blue,
# light gray, light green, light blue, dark magenta, dark cyan, dark red,
# light magenta, light cyan, light red.
[view]
dynamic_days = True
frame = color
theme = dark
[locale]
default_timezone = Europe/Madrid
local_timezone = Europe/Madrid
timeformat = %H:%M
dateformat= %m-%d
longdateformat= %Y-%m-%d
datetimeformat= %m-%d %H:%M
longdatetimeformat= %Y-%m-%d %H:%M
'';
home.file.".config/khard/khard.conf".text = ''
[addressbooks]
[[default]]
path = ${contacts}/nextcloud/contacts/
[[google]]
path = ${contacts}/google/default/
[general]
debug = no
default_action = list
# These are either strings or comma seperated lists
editor = vim, -i, NONE
merge_editor = vimdiff
[contact table]
# display names by first or last name: first_name / last_name / formatted_name
display = first_name
# group by address book: yes / no
group_by_addressbook = no
# reverse table ordering: yes / no
reverse = no
# append nicknames to name column: yes / no
show_nicknames = no
# show uid table column: yes / no
show_uids = yes
# sort by first or last name: first_name / last_name / formatted_name
sort = last_name
# localize dates: yes / no
localize_dates = yes
# set a comma separated list of preferred phone number types in descending priority
# or nothing for non-filtered alphabetical order
preferred_phone_number_type = pref, cell, home
# set a comma separated list of preferred email address types in descending priority
# or nothing for non-filtered alphabetical order
preferred_email_address_type = pref, work, home
[vcard]
# extend contacts with your own private objects
# these objects are stored with a leading "X-" before the object name in the vcard files
# every object label may only contain letters, digits and the - character
# example:
# private_objects = Jabber, Skype, Twitter
# default: , (the empty list)
private_objects = Jabber, Skype, Twitter
# preferred vcard version: 3.0 / 4.0
preferred_version = 3.0
# Look into source vcf files to speed up search queries: yes / no
search_in_source_files = no
# skip unparsable vcard files: yes / no
skip_unparsable = no
'';
}