From 782eed8bb64b27acaeb7c17be4a095c85e65717f Mon Sep 17 00:00:00 2001 From: "O. C. Taskin" <42993892+octvs@users.noreply.github.com> Date: Fri, 5 Apr 2024 13:48:20 +0200 Subject: [PATCH] programs.khal: add "addresses" option + tidy up (#5221) - Add `accounts..accounts..khal.addresses` option to enable new configuration option, "addresses", from khal, which is used for showing participation status [1]. - Remove mistaken new line in khal implementation, refer to [2]. - Make additions to the existing test case to check the new addresses feature. And remove the empty lines in expected configs. [1]: https://khal.readthedocs.io/en/latest/configure.html#the-calendars-section [2]: https://github.com/nix-community/home-manager/pull/5192#pullrequestreview-1975091763 --- modules/programs/khal-accounts.nix | 9 ++++++ modules/programs/khal.nix | 4 ++- tests/modules/programs/khal/config.nix | 28 +++++++++++++++++++ .../programs/khal/khal-config-expected | 20 ++++++++++--- 4 files changed, 56 insertions(+), 5 deletions(-) diff --git a/modules/programs/khal-accounts.nix b/modules/programs/khal-accounts.nix index 846e18fa..bbf222d9 100644 --- a/modules/programs/khal-accounts.nix +++ b/modules/programs/khal-accounts.nix @@ -31,5 +31,14 @@ with lib; Priority of a calendar used for coloring (calendar with highest priority is preferred). ''; }; + + addresses = mkOption { + type = types.listOf types.str; + default = [ ]; + description = '' + Email addresses to be associated with this account. Used to check the + participation status ("PARTSTAT"), refer to khal documentation. + ''; + }; }; } diff --git a/modules/programs/khal.nix b/modules/programs/khal.nix index 52e77963..50ccb681 100644 --- a/modules/programs/khal.nix +++ b/modules/programs/khal.nix @@ -45,8 +45,10 @@ let + (optionalString (value.khal.type == "birthdays" && value.khal ? thisCollection) value.khal.thisCollection) - }\n " + }" ] ++ optional (value.khal.readOnly) "readonly = True" + ++ optional (value.khal.addresses != [ ]) + "addresses= ${lib.concatStringsSep ", " value.khal.addresses}" ++ optional (value.khal.color != null) "color = '${value.khal.color}'" ++ [ (toKeyValueIfDefined (getAttrs [ "type" "priority" ] value.khal)) ] ++ [ "\n" ]); diff --git a/tests/modules/programs/khal/config.nix b/tests/modules/programs/khal/config.nix index 017a04ac..c4a35945 100644 --- a/tests/modules/programs/khal/config.nix +++ b/tests/modules/programs/khal/config.nix @@ -30,6 +30,34 @@ url = "https://example.com/events.ical"; }; }; + testWithAddresss = { + khal = { + enable = true; + addresses = [ "john.doe@email.com" ]; + }; + local = { + type = "filesystem"; + fileExt = ".ics"; + }; + remote = { + type = "http"; + url = "https://example.com/events.ical"; + }; + }; + testWithMultipleAddresss = { + khal = { + enable = true; + addresses = [ "john.doe@email.com" "another.brick@on.the.wall" ]; + }; + local = { + type = "filesystem"; + fileExt = ".ics"; + }; + remote = { + type = "http"; + url = "https://example.com/events.ical"; + }; + }; }; }; diff --git a/tests/modules/programs/khal/khal-config-expected b/tests/modules/programs/khal/khal-config-expected index 157d650b..32fe7270 100644 --- a/tests/modules/programs/khal/khal-config-expected +++ b/tests/modules/programs/khal/khal-config-expected @@ -1,7 +1,6 @@ [calendars] [[test]] path = /home/hm-user/$XDG_CONFIG_HOME/cal/test/ - readonly = True color = '#ff0000' priority=10 @@ -9,9 +8,24 @@ type=calendar +[[testWithAddresss]] +path = /home/hm-user/$XDG_CONFIG_HOME/cal/testWithAddresss/ +addresses= john.doe@email.com +priority=10 +type=calendar + + + +[[testWithMultipleAddresss]] +path = /home/hm-user/$XDG_CONFIG_HOME/cal/testWithMultipleAddresss/ +addresses= john.doe@email.com, another.brick@on.the.wall +priority=10 +type=calendar + + + [[testcontacts-automaticallyCollected]] path = /home/hm-user/$XDG_CONFIG_HOME/card/testcontacts/automaticallyCollected - priority=10 type=birthdays @@ -19,7 +33,6 @@ type=birthdays [[testcontacts-default]] path = /home/hm-user/$XDG_CONFIG_HOME/card/testcontacts/default - priority=10 type=birthdays @@ -27,7 +40,6 @@ type=birthdays [[testcontactsNoCollections]] path = /home/hm-user/$XDG_CONFIG_HOME/card/testcontactsNoCollections/ - priority=10 type=birthdays