blob: 09452513d64010e886b15a98883b35990e812fe5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.services.icaldavsync;
curl = "${pkgs.curl}/bin/curl";
updateApiUrl = "${cfg.caldavServerUrl}/${cfg.user}/${cfg.calendar}";
in
{
options.services.icaldavsync = {
enable = mkEnableOption "ical caldav sync";
syncFrequency = mkOption { type = types.str; default = "*:0/30"; };
icalLink = mkOption { type = types.str; };
caldavServerUrl = mkOption { type = types.str; };
user = mkOption { type = types.str; };
password = mkOption { type = types.str; };
calendar = mkOption { type = types.str; };
};
config = mkIf cfg.enable {
systemd.user.services.icaldavsync = {
enable = true;
script = ''
set -eu -o pipefail;
${curl} '${cfg.icalLink}' | ${curl} -X PUT '${updateApiUrl}' -u '${cfg.user}:${cfg.password}' --data-binary @-;
'';
serviceConfig = {
Type = "oneshot";
};
startAt = cfg.syncFrequency;
};
};
}
|