mirror of
https://github.com/nix-community/home-manager
synced 2024-11-24 03:59:46 +01:00
e8abc2ac53
This also adds the modules - programs.vdirsyncer, - programs.khal, and - services.vdirsyncer that integrate with the new infrastructure. Co-authored-by: Andrew Scott <3648487+ayyjayess@users.noreply.github.com> Co-authored-by: Sebastian Zivota <sebastian.zivota@mailbox.org>
64 lines
1.6 KiB
Nix
64 lines
1.6 KiB
Nix
# khal config loader is sensitive to leading space !
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.programs.khal;
|
|
|
|
khalCalendarAccounts = filterAttrs (_: a: a.khal.enable)
|
|
(config.accounts.calendar.accounts);
|
|
|
|
khalContactAccounts = mapAttrs (_: v: v // {type = "birthdays";})
|
|
(filterAttrs (_: a: a.khal.enable)
|
|
(config.accounts.contact.accounts));
|
|
|
|
khalAccounts = khalCalendarAccounts // khalContactAccounts;
|
|
|
|
primaryAccount = findSingle (a: a.primary) null null
|
|
(mapAttrsToList (n: v: v // {name= n;}) khalAccounts);
|
|
in
|
|
|
|
{
|
|
options.programs.khal = {
|
|
enable = mkEnableOption "khal, a CLI calendar application";
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
home.packages = [ pkgs.khal ];
|
|
|
|
xdg.configFile."khal/config".text = concatStringsSep "\n" (
|
|
[
|
|
"[calendars]"
|
|
]
|
|
++ (mapAttrsToList (name: value: concatStringsSep "\n"
|
|
([
|
|
''[[${name}]]''
|
|
''path = ${value.local.path + "/" + (optionalString (value.khal.type == "discover") value.khal.glob)}''
|
|
]
|
|
++ optional (value.khal.readOnly) "readonly = True"
|
|
++ optional (!isNull value.khal.type) "type = ${value.khal.type}"
|
|
++ ["\n"]
|
|
)
|
|
) khalAccounts)
|
|
++
|
|
[
|
|
(generators.toINI {} {
|
|
default = optionalAttrs (!isNull primaryAccount) {
|
|
default_calendar = if isNull primaryAccount.primaryCollection then primaryAccount.name else primaryAccount.primaryCollection;
|
|
};
|
|
|
|
locale = {
|
|
timeformat = "%H:%M";
|
|
dateformat = "%Y-%m-%d";
|
|
longdateformat = "%Y-%m-%d";
|
|
datetimeformat = "%Y-%m-%d %H:%M";
|
|
longdatetimeformat = "%Y-%m-%d %H:%M";
|
|
weeknumbers = "right";
|
|
};
|
|
})
|
|
]
|
|
);
|
|
};
|
|
}
|