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:
parent
20c7963471
commit
c3abf8ea1a
4 changed files with 60 additions and 1 deletions
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -4,4 +4,5 @@
|
|||
khard_multiple_accounts = ./multiple_accounts.nix;
|
||||
khard_dirty_path = ./dirty_path.nix;
|
||||
khard_multiple_with_abooks = ./multiple_with_abooks.nix;
|
||||
khard_discover_type = ./discover_type.nix;
|
||||
}
|
||||
|
|
|
|||
20
tests/modules/programs/khard/discover_type.nix
Normal file
20
tests/modules/programs/khard/discover_type.nix
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
accounts.contact = {
|
||||
basePath = ".contacts";
|
||||
accounts.test = {
|
||||
local.type = "filesystem";
|
||||
khard = {
|
||||
enable = true;
|
||||
type = "discover";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
programs.khard.enable = true;
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContent \
|
||||
home-files/.config/khard/khard.conf \
|
||||
${./discover_type_expected}
|
||||
'';
|
||||
}
|
||||
9
tests/modules/programs/khard/discover_type_expected
Normal file
9
tests/modules/programs/khard/discover_type_expected
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
[addressbooks]
|
||||
[[test]]
|
||||
path = /home/hm-user/.contacts/test/*
|
||||
type = discover
|
||||
|
||||
|
||||
[general]
|
||||
default_action=list
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue