blob: 307641fdbcec16bf53233c5e73fd05f56646436c (
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
# 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; };
calendarNames = builtins.attrNames cfg.calendars;
usableColors = with base16Colors.colorsWithHashPrefix; [
base08
base09
base0A
base0B
base0C
base0D
base0E
base0F
];
calendarColors = builtins.listToAttrs (
lib.imap0 (index: name: {
inherit name;
value = builtins.elemAt usableColors (lib.mod index (builtins.length usableColors));
}) calendarNames
);
in
{
imports = [ ./assertions.nix ];
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.";
};
calendars = lib.mkOption {
type = lib.types.attrsOf (
lib.types.submodule (
{ name, ... }: {
options = {
read-only = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Whether khal may modify this calendar.";
};
primary = lib.mkOption {
type = lib.types.bool;
default = name == "personal";
description = "Whether khal should use this calendar for new events by default.";
};
};
}
)
);
default.personal = { };
description = "Named vdir calendars managed by khal.";
};
};
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_dayevent_duration = "1d";
default_event_duration = "1h";
enable_mouse = true;
highlight_event_days = false;
timedelta = "2d";
};
settings.view.theme = "dark";
};
accounts.calendar = {
basePath = calendarPath;
accounts = lib.mapAttrs (_name: calendar: {
primary = calendar.primary;
khal = {
enable = true;
color = calendarColors.${_name};
readOnly = calendar.read-only;
};
local = {
path = "${calendarPath}/${_name}";
type = "filesystem";
};
}) cfg.calendars;
};
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";
};
};
}
|