infra/hosts/www/dav2ical.nix
2026-07-14 19:36:08 +02:00

38 lines
831 B
Nix

{ config, pkgs, ... }:
let
outputDir = "/srv/http/calendars";
script = pkgs.writeScript "caldav-export.py" ''
#!${pkgs.python3}/bin/python3
${builtins.readFile ./caldav-export.py}
'';
pythonEnv = pkgs.python3.withPackages (
ps: with ps; [
caldav
icalendar
pyyaml
]
);
in
{
systemd = {
services.caldav-export = {
description = "Export CalDAV calendars to ICS";
serviceConfig = {
Type = "oneshot";
ExecStart = "${pythonEnv}/bin/python ${script} ${config.age.secrets.caldav-export-config.path} -o ${outputDir}";
};
};
timers.caldav-export = {
description = "Daily CalDAV export";
wantedBy = [
"timers.target"
];
timerConfig = {
OnCalendar = "daily";
Persistent = true;
};
};
};
}