From 1ec38f94c8c8d07a23dec4159fff43ec085bfb9b Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Sun, 29 Sep 2024 11:28:52 +0100 Subject: [PATCH] Add calendar configuration Use vdirsyncer to sync with xandikos server. Add khal for calendar management. --- system/home/desktop.nix | 3 +- system/home/services/calendar/default.nix | 66 +++++++++++++++++++ .../calendar/vdirsyncer-ensure-pass.sh | 5 ++ 3 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 system/home/services/calendar/default.nix create mode 100644 system/home/services/calendar/vdirsyncer-ensure-pass.sh diff --git a/system/home/desktop.nix b/system/home/desktop.nix index 4279c67b..5636d37f 100644 --- a/system/home/desktop.nix +++ b/system/home/desktop.nix @@ -7,6 +7,7 @@ ./browser/default.nix ./zathura/default.nix ./services/email/default.nix + ./services/calendar/default.nix ]; home.packages = with pkgs; [ webcord @@ -18,7 +19,7 @@ programs.mpv.enable = true; gtk = { enable = true; - gtk2.configLocation = "${config.xdg.configHome}/gtk-2.0/gtkrc"; + gtk2.configLocation = "${config.xdg.configHome}/gtk-2.0/dummyrc"; # Stop clashing with KDE iconTheme = { package = pkgs.papirus-icon-theme; name = "Papirus"; diff --git a/system/home/services/calendar/default.nix b/system/home/services/calendar/default.nix new file mode 100644 index 00000000..c4750025 --- /dev/null +++ b/system/home/services/calendar/default.nix @@ -0,0 +1,66 @@ +{ config, pkgs, ... }: +{ + home.packages = [ + (pkgs.writeShellScriptBin "vdirsyncer-ensure-pass" (builtins.readFile ./vdirsyncer-ensure-pass.sh)) + ]; + programs = { + vdirsyncer.enable = true; + khal = { + enable = true; + locale = { + timeformat = "%H:%M"; + dateformat = "%Y-%m-%d"; + longdateformat = "%Y-%m-%d %a"; + datetimeformat = "%Y-%m-%d %H:%M"; + longdatetimeformat = "%Y-%m-%d %H:%M"; + }; + }; + }; + services.vdirsyncer.enable = true; + accounts.calendar = { + basePath = "Calendar"; + accounts = { + personal = + let + url = "dav.xenia.me.uk"; + in + { + primary = true; + primaryCollection = "calendar"; + local = { + type = "filesystem"; + fileExt = ".ics"; + }; + remote = { + url = "https://${url}"; + type = "caldav"; + userName = "pixelifytica"; + passwordCommand = [ + "${pkgs.libsecret}/bin/secret-tool" + "lookup" + "url" + "${url}" + ]; + }; + vdirsyncer = { + inherit (config.programs.vdirsyncer) enable; + auth = "basic"; + collections = [ "from a" ]; + metadata = [ + "color" + "displayname" + ]; + timeRange = { + start = "datetime.now() - timedelta(days=365)"; + end = "datetime.now() + timedelta(days=365)"; + }; + }; + khal = { + inherit (config.programs.khal) enable; + type = "discover"; + addresses = with config.accounts.email.accounts.proton; [ address ] ++ aliases; + }; + }; + }; + }; +} diff --git a/system/home/services/calendar/vdirsyncer-ensure-pass.sh b/system/home/services/calendar/vdirsyncer-ensure-pass.sh new file mode 100644 index 00000000..806b2526 --- /dev/null +++ b/system/home/services/calendar/vdirsyncer-ensure-pass.sh @@ -0,0 +1,5 @@ +URL="dav.xenia.me.uk" +secret-tool lookup url "$URL" >/dev/null || ( + echo "Setup calendar password" + secret-tool store --label="Calendar vdirsyncer" url "$URL" +)