khard: support discover entries (#7785)

This adds support for discover type entries, which were introduced in
khard 0.20.0, which work very similar to the equally-named khal feature.
This commit is contained in:
Anton Mosich 2025-09-14 00:31:16 +00:00 committed by GitHub
parent 20c7963471
commit c3abf8ea1a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 60 additions and 1 deletions

View file

@ -107,6 +107,26 @@ in
default value will set the aforementioned path as a single vdir.
'';
};
options.khard.type = lib.mkOption {
type = types.enum [
"vdir"
"discover"
];
default = "vdir";
description = ''
Either a single vdir located in [](#opt-accounts.contact.accounts._name_.local.path)
or multiple automatically discovered vdirs in
[](#opt-accounts.contact.accounts._name_.local.path)/[](#opt-accounts.contact.accounts._name_.khard.glob).
'';
};
options.khard.glob = lib.mkOption {
type = lib.types.str;
default = "*";
description = ''
The glob expansion to be searched for contacts when
type is set to discover.
'';
};
}
);
};
@ -131,11 +151,20 @@ in
[[${makeName anAccount.name anAbook}]]
path = ${makePath anAccount.local.path anAbook}
'';
makeDiscoverEntry = anAccount: ''
[[${makeName anAccount.name ""}]]
path = ${anAccount.local.path}/${anAccount.khard.glob}
type = discover
'';
in
''
[addressbooks]
${lib.concatMapStringsSep "\n" (
acc: lib.concatMapStringsSep "\n" (makeEntry acc) acc.khard.addressbooks
acc:
if acc.khard.type == "discover" then
makeDiscoverEntry acc
else
lib.concatMapStringsSep "\n" (makeEntry acc) acc.khard.addressbooks
) (lib.attrValues accounts)}
${renderSettings cfg.settings}