1
0
Fork 0

Aktualisiere Kalender

This commit is contained in:
Malte Brandy 2021-02-14 21:19:25 +01:00
parent 76f9b5d562
commit 2bf76bca91
No known key found for this signature in database
GPG key ID: 226A2D41EF5378C9
3 changed files with 68 additions and 48 deletions

View file

@ -7,10 +7,19 @@
#agenda_event_format = "{calendar-color}{cancelled}{start-end-time-style} {title}{repeat-symbol}"
#event_format = "{calendar-color}{cancelled}{start-end-time-style} {title}{repeat-symbol}"
file.".config/khal/config".text = ''
[default]
default_calendar = Standard
[calendars]
[[all]]
[[clouds]]
type = discover
path = ~/.calendars/*/*
path = ~/.calendars/*cloud/*
[[cda]]
type = discover
path = ~/.calendars/cccda/*
[[readonly]]
type = discover
readonly = True
path = ~/.calendars/*readonly/*
'';
};
}

View file

@ -1,64 +1,75 @@
{ pkgs, lib, ... }:
let
addressbooks = pkgs.privateValue [ ] "addressbooks";
calendars = pkgs.privateValue [ ] "calendars";
addressbooks = pkgs.privateValue [] "addressbooks";
calendars = pkgs.privateValue [] "calendars";
mkConfig = config:
(pkgs.formats.ini { }).generate "vdirsyncer-config" (lib.mapAttrs
(name: section:
(lib.mapAttrs (name: option: builtins.toJSON option) section)) config);
mkCalendar = { name, url, username, passwordPath }:
(pkgs.formats.ini {}).generate "vdirsyncer-config" (
lib.mapAttrs
(
name: section:
(lib.mapAttrs (name: option: builtins.toJSON option) section)
) config
);
mkCalendar = { name, url, username, passwordPath, collections ? [ "from a" "from b" ], readOnly ? false }:
let
pairName = "${name}_calendar";
remoteName = "${pairName}_remote";
localName = "${pairName}_local";
in {
"pair ${pairName}" = {
a = localName;
b = remoteName;
collections = [ "from a" "from b" ];
conflict_resolution = "b wins";
in
{
"pair ${pairName}" = {
a = localName;
b = remoteName;
inherit collections;
conflict_resolution = "b wins";
metadata = ["color"];
};
"storage ${localName}" = {
type = "filesystem";
path = "~/.calendars/${name}/";
fileext = ".ics";
};
"storage ${remoteName}" = {
type = "caldav";
inherit url username;
"password.fetch" = [ "command" "${pkgs.pass}/bin/pass" passwordPath ];
};
};
"storage ${localName}" = {
type = "filesystem";
path = "~/.calendars/${name}/";
fileext = ".ics";
};
"storage ${remoteName}" = {
type = "caldav";
inherit url username;
"password.fetch" = [ "command" "${pkgs.pass}/bin/pass" passwordPath ];
};
};
mkAddressbook = { name, url, username, passwordPath }:
mkAddressbook = { name, url, username, passwordPath, collections ? [ "from a" "from b" ], readOnly ? false }:
let
pairName = "${name}_contacts";
remoteName = "${pairName}_remote";
localName = "${pairName}_local";
in {
"pair ${pairName}" = {
a = localName;
b = remoteName;
collections = [ "from a" "from b" ];
conflict_resolution = "b wins";
in
{
"pair ${pairName}" = {
a = localName;
b = remoteName;
inherit collections;
conflict_resolution = "b wins";
};
"storage ${localName}" = {
type = "filesystem";
path = "~/.contacts/${name}/";
fileext = ".vcf";
};
"storage ${remoteName}" = {
type = "carddav";
inherit url username;
"password.fetch" = [ "command" "${pkgs.pass}/bin/pass" passwordPath ];
read_only = readOnly;
};
};
"storage ${localName}" = {
type = "filesystem";
path = "~/.contacts/${name}/";
fileext = ".vcf";
};
"storage ${remoteName}" = {
type = "carddav";
inherit url username;
"password.fetch" = [ "command" "${pkgs.pass}/bin/pass" passwordPath ];
};
};
in {
in
{
home = {
packages = [ pkgs.vdirsyncer ];
file.".config/vdirsyncer/config".source = mkConfig
(pkgs.lib.fold (a: b: a // b) {
general.status_path = "~/.vdirsyncer/status";
} (map mkCalendar calendars ++ map mkAddressbook addressbooks));
(
pkgs.lib.fold (a: b: a // b) {
general.status_path = "~/.vdirsyncer/status";
} (map mkCalendar calendars ++ map mkAddressbook addressbooks)
);
};
systemd.user = {

@ -1 +1 @@
Subproject commit 3f79197d655edf1895c508ad5250859c86e6ac27
Subproject commit 83bfe691f4ac9e203c29b8b4f0cbb570a497af1c