aboutsummaryrefslogtreecommitdiffstats
path: root/modules/office/khal/default.nix
blob: 8d924f5ebc2ecbe90d34230e791bda0498c1f933 (plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# CLI calendar application (khal)
{
  config,
  lib,
  pkgs,
  ...
}:
let
  cfg = config.office.khal;
  icons = config.desktop.icons.apps;
  calendarPath = "${config.xdg.dataHome}/khal/calendars";
  base16Colors = import ../../colors/base16 { inherit config lib pkgs; };
in
{
  options.office.khal = {
    enable = lib.mkEnableOption "khal, a CLI calendar application";
    package = lib.mkOption {
      type = lib.types.package;
      readOnly = true;
      default = config.programs.khal.package;
      description = "The khal package to use.";
    };
  };

  config = lib.mkIf cfg.enable {
    programs.khal = {
      enable = true;
      locale = {
        timeformat = "%H:%M";
        dateformat = "%Y-%m-%d";
        longdateformat = "%Y-%m-%d";
        datetimeformat = "%Y-%m-%d %H:%M";
        longdatetimeformat = "%Y-%m-%d %H:%M";
      };
      settings.default = {
        default_calendar = "personal";
        default_dayevent_duration = "1d";
        default_event_duration = "1h";
        enable_mouse = true;
        timedelta = "2d";
      };
      settings.view.theme = "dark";
    };

    accounts.calendar = {
      basePath = calendarPath;
      accounts.personal = {
        khal = {
          enable = true;
          color = base16Colors.colorsWithHashPrefix.base0D;
        };
        local.type = "filesystem";
      };
    };

    xdg.desktopEntries."khal" = lib.mkIf (config.terminal.kitty.enable && cfg.package != null) {
      name = "khal";
      exec = "${lib.getExe config.terminal.kitty.package} --class khal -e ${lib.getExe' cfg.package "khal"} interactive";
      icon = icons.khal or "calendar";
      categories = [
        "Office"
        "Calendar"
      ];
      comment = "CLI calendar application";
      terminal = false;
      type = "Application";
    };
  };
}