Skip to content

Commit

Permalink
programs.khal: add "addresses" option + tidy up (nix-community#5221)
Browse files Browse the repository at this point in the history
- Add `accounts.<calendar|contact>.accounts.<name>.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]: nix-community#5192 (review)
  • Loading branch information
octvs committed Apr 5, 2024
1 parent 1ffd393 commit 782eed8
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 5 deletions.
9 changes: 9 additions & 0 deletions modules/programs/khal-accounts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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.
'';
};
};
}
4 changes: 3 additions & 1 deletion modules/programs/khal.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]);
Expand Down
28 changes: 28 additions & 0 deletions tests/modules/programs/khal/config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
};
};
};
};

Expand Down
20 changes: 16 additions & 4 deletions tests/modules/programs/khal/khal-config-expected
Original file line number Diff line number Diff line change
@@ -1,33 +1,45 @@
[calendars]
[[test]]
path = /home/hm-user/$XDG_CONFIG_HOME/cal/test/

readonly = True
color = '#ff0000'
priority=10
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



[[testcontacts-default]]
path = /home/hm-user/$XDG_CONFIG_HOME/card/testcontacts/default

priority=10
type=birthdays



[[testcontactsNoCollections]]
path = /home/hm-user/$XDG_CONFIG_HOME/card/testcontactsNoCollections/

priority=10
type=birthdays

Expand Down

0 comments on commit 782eed8

Please sign in to comment.