programs.khal: add settings option (#4375)

This commit is contained in:
arjan-s 2023-08-30 11:57:47 +02:00 committed by GitHub
parent 8bde7a651b
commit a7eab56be5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 62 additions and 4 deletions

View file

@ -7,6 +7,8 @@ let
cfg = config.programs.khal;
iniFormat = pkgs.formats.ini { };
khalCalendarAccounts =
filterAttrs (_: a: a.khal.enable) config.accounts.calendar.accounts;
@ -147,6 +149,7 @@ let
in {
options.programs.khal = {
enable = mkEnableOption "khal, a CLI calendar application";
locale = mkOption {
type = lib.types.submodule { options = localeOptions; };
description = ''
@ -154,6 +157,25 @@ in {
'';
default = { };
};
settings = mkOption {
type = iniFormat.type;
default = { };
example = literalExpression ''
{
default = {
default_calendar = "Calendar";
timedelta = "5d";
};
view = {
agenda_event_format =
"{calendar-color}{cancelled}{start-end-time-style} {title}{repeat-symbol}{reset}";
};
}'';
description = ''
Configuration options to add to the various sections in the configuration file.
'';
};
};
config = mkIf cfg.enable {
@ -161,7 +183,7 @@ in {
xdg.configFile."khal/config".text = concatStringsSep "\n" ([ "[calendars]" ]
++ mapAttrsToList genCalendarStr khalAccounts ++ [
(generators.toINI { } {
(generators.toINI { } (recursiveUpdate cfg.settings {
locale = definedAttrs (cfg.locale // { _module = null; });
default = optionalAttrs (!isNull primaryAccount) {
@ -171,7 +193,7 @@ in {
else
primaryAccount.primaryCollection;
};
})
}))
]);
};
}