{ 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; }; }; }; }