nix-configs/modules/user-services/khal.nix

63 lines
1.7 KiB
Nix

{
pkgs,
config,
lib,
...
}:
let
cfg = config.xyno.user-services.khal;
in
{
options.xyno.user-services.khal.enable = lib.mkEnableOption "enable khal and vdirsyncer";
options.xyno.user-services.khal.wantedBy = lib.mkOption {
type = lib.types.str;
default = "niri.service";
};
config = lib.mkIf cfg.enable {
environment.systemPackages = [
pkgs.khal
pkgs.vdirsyncer
];
systemd.packages = [ pkgs.vdirsyncer ];
environment.etc."xdg/khal/config".text = ''
[locale]
weeknumbers = right
timeformat = "%H:%M"
longdatetimeformat = "%Y-%m-%dT%H:%M:%S"
datetimeformat = "%Y-%m-%dT%H:%M:%S"
dateformat = "%Y-%m-%d"
longdateformat = "%Y-%m-%d"
[calendars]
[[calendars]]
path = ~/.calendars/*
type = discover
'';
systemd.user.services.vdirsyncer = {
environment.VDIRSYNCER_CONFIG = config.sops.secrets."vdirsyncer".path;
unitConfig = {
After = "network-online.target";
Wants = "network-online.target";
};
serviceConfig = {
Type = "oneshot";
};
script = ''
${pkgs.vdirsyncer}/bin/vdirsyncer metasync
${pkgs.vdirsyncer}/bin/vdirsyncer sync
'';
};
systemd.user.timers.vdirsyncer = {
wantedBy = [ cfg.wantedBy "timers.target" ];
timerConfig = {
OnCalendar = "*:0/15:00";
Unit = "vdirsyncer.service";
};
};
environment.sessionVariables.VDIRSYNCER_CONFIG = config.sops.secrets."vdirsyncer".path;
sops.secrets."vdirsyncer" = {
sopsFile = ../../secrets/desktop/calendar.yaml;
group = "users";
owner = config.xyno.system.user.name;
};
};
}