nixos-config/user/vdir.nix

88 lines
2.2 KiB
Nix
Raw Normal View History

2023-01-25 00:26:39 -03:00
{ pkgs, lib, ... }:
let
inherit (pkgs.uservars) nextcloud;
pass_cmd = (
pkgs.writeShellScript "get_pass" ''
pass "${nextcloud.pass}" | head -n1
''
);
2023-01-25 00:26:39 -03:00
in
{
systemd.user.services.vdirsyncer = {
2023-02-18 12:15:05 -03:00
Unit.Description = "vdirsyncer calendar and contacts synchronization";
2023-01-25 00:26:39 -03:00
Service = {
Type = "oneshot";
ExecStart = toString (
pkgs.writeShellScript "run-vdirsyncer" ''
${pkgs.coreutils}/bin/yes | ${pkgs.vdirsyncer}/bin/vdirsyncer discover
${pkgs.coreutils}/bin/yes | ${pkgs.vdirsyncer}/bin/vdirsyncer sync
''
);
2023-01-25 00:26:39 -03:00
};
};
systemd.user.timers.vdirsyncer = {
2023-02-18 12:15:05 -03:00
Unit.Description = "vdirsyncer calendar and contacts synchronization";
2023-01-25 00:26:39 -03:00
Timer = {
OnCalendar = "*:0/30";
Unit = "vdirsyncer.service";
};
2023-02-18 12:15:05 -03:00
Install.WantedBy = [ "timers.target" ];
2023-01-25 00:26:39 -03:00
};
xdg.configFile = {
"vdirsyncer/config".text = ''
[general]
status_path = "~/.vdirsyncer/status/"
[pair contacts]
a = "contacts_local"
b = "contacts_remote"
collections = ["from a", "from b"]
metadata = ["displayname"]
[storage contacts_local]
type = "filesystem"
path = "~/.local/share/contacts/"
fileext = ".vcf"
[storage contacts_remote]
type = "carddav"
url = "https://${nextcloud.host}/remote.php/dav/addressbooks/users/${nextcloud.user}/"
username = "${nextcloud.user}"
password.fetch = [ "command", "${pass_cmd}" ]
2023-01-25 00:26:39 -03:00
[pair calendar]
a = "calendar_local"
b = "calendar_remote"
collections = ["from a", "from b"]
metadata = ["displayname", "color"]
2023-08-31 14:09:37 -03:00
conflict_resolution = "b wins"
2023-01-25 00:26:39 -03:00
[storage calendar_local]
type = "filesystem"
path = "~/.local/share/calendars/"
fileext = ".ics"
[storage calendar_remote]
type = "caldav"
url = "https://${nextcloud.host}/remote.php/dav/calendars/${nextcloud.user}/"
username = "${nextcloud.user}"
password.fetch = [ "command", "${pass_cmd}" ]
2023-01-25 00:26:39 -03:00
'';
"todoman/config.py".text = ''
path = "~/.local/share/calendars/*"
date_format = "%Y-%m-%d"
time_format = "%H:%M"
default_list = "Personal"
default_due = 48
'';
};
home.packages = with pkgs; [
vdirsyncer
todoman
];
}