1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-30 06:59:45 +01:00

programs.khal: add "addresses" option + tidy up (#5221)

- 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]: https://github.com/nix-community/home-manager/pull/5192#pullrequestreview-1975091763
This commit is contained in:
O. C. Taskin 2024-04-05 13:48:20 +02:00 committed by GitHub
parent 1ffd393cba
commit 782eed8bb6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 56 additions and 5 deletions

View file

@ -31,5 +31,14 @@ with lib;
Priority of a calendar used for coloring (calendar with highest priority is preferred). 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.
'';
};
}; };
} }

View file

@ -45,8 +45,10 @@ let
+ (optionalString + (optionalString
(value.khal.type == "birthdays" && value.khal ? thisCollection) (value.khal.type == "birthdays" && value.khal ? thisCollection)
value.khal.thisCollection) value.khal.thisCollection)
}\n " }"
] ++ optional (value.khal.readOnly) "readonly = True" ] ++ 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}'" ++ optional (value.khal.color != null) "color = '${value.khal.color}'"
++ [ (toKeyValueIfDefined (getAttrs [ "type" "priority" ] value.khal)) ] ++ [ (toKeyValueIfDefined (getAttrs [ "type" "priority" ] value.khal)) ]
++ [ "\n" ]); ++ [ "\n" ]);

View file

@ -30,6 +30,34 @@
url = "https://example.com/events.ical"; 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";
};
};
}; };
}; };

View file

@ -1,7 +1,6 @@
[calendars] [calendars]
[[test]] [[test]]
path = /home/hm-user/$XDG_CONFIG_HOME/cal/test/ path = /home/hm-user/$XDG_CONFIG_HOME/cal/test/
readonly = True readonly = True
color = '#ff0000' color = '#ff0000'
priority=10 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]] [[testcontacts-automaticallyCollected]]
path = /home/hm-user/$XDG_CONFIG_HOME/card/testcontacts/automaticallyCollected path = /home/hm-user/$XDG_CONFIG_HOME/card/testcontacts/automaticallyCollected
priority=10 priority=10
type=birthdays type=birthdays
@ -19,7 +33,6 @@ type=birthdays
[[testcontacts-default]] [[testcontacts-default]]
path = /home/hm-user/$XDG_CONFIG_HOME/card/testcontacts/default path = /home/hm-user/$XDG_CONFIG_HOME/card/testcontacts/default
priority=10 priority=10
type=birthdays type=birthdays
@ -27,7 +40,6 @@ type=birthdays
[[testcontactsNoCollections]] [[testcontactsNoCollections]]
path = /home/hm-user/$XDG_CONFIG_HOME/card/testcontactsNoCollections/ path = /home/hm-user/$XDG_CONFIG_HOME/card/testcontactsNoCollections/
priority=10 priority=10
type=birthdays type=birthdays