1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-23 11:39:46 +01:00

khard: add option to contact module for khard dir

Add an extra option,

    accounts.contact.accounts.<name>.khard.defaultCollection

to hardcode a subdirectory for khard to function as intended. Khard
expects to be given a collection directory directly, from which there
can be multiple of in a vdir. This contrasts khal or vdirsyncer which
support recursive search.

Fixes #4531
This commit is contained in:
O. C. Taskin 2024-07-16 15:17:37 +02:00 committed by GitHub
parent 90ae324e2c
commit a38f88045e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 44 additions and 2 deletions

View file

@ -68,6 +68,11 @@ in {
type = with lib.types; type = with lib.types;
attrsOf (submodule { attrsOf (submodule {
options.khard.enable = lib.mkEnableOption "khard access"; options.khard.enable = lib.mkEnableOption "khard access";
options.khard.defaultCollection = lib.mkOption {
type = types.str;
default = "";
description = "VCARD collection to be searched by khard.";
};
}); });
}; };
}; };
@ -75,11 +80,17 @@ in {
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
home.packages = [ pkgs.khard ]; home.packages = [ pkgs.khard ];
xdg.configFile."khard/khard.conf".text = '' xdg.configFile."khard/khard.conf".text = let
makePath = anAccount:
builtins.toString (/. + lib.concatStringsSep "/" [
anAccount.local.path
anAccount.khard.defaultCollection
]);
in ''
[addressbooks] [addressbooks]
${lib.concatMapStringsSep "\n" (acc: '' ${lib.concatMapStringsSep "\n" (acc: ''
[[${acc.name}]] [[${acc.name}]]
path = ${acc.local.path} path = ${makePath acc}
'') (lib.attrValues accounts)} '') (lib.attrValues accounts)}
${renderSettings cfg.settings} ${renderSettings cfg.settings}

View file

@ -2,4 +2,5 @@
khard_empty_config = ./empty_config.nix; khard_empty_config = ./empty_config.nix;
khard_basic_config = ./basic_config.nix; khard_basic_config = ./basic_config.nix;
khard_multiple_accounts = ./multiple_accounts.nix; khard_multiple_accounts = ./multiple_accounts.nix;
khard_dirty_path = ./dirty_path.nix;
} }

View file

@ -0,0 +1,22 @@
{
accounts.contact = {
basePath = "/home/user/who/likes///";
accounts.forward = {
local.type = "filesystem";
khard = {
enable = true;
defaultCollection = "////slashes//a/lot";
};
};
};
programs.khard.enable = true;
test.stubs.khard = { };
nmt.script = ''
assertFileContent \
home-files/.config/khard/khard.conf \
${./dirty_path_expected}
'';
}

View file

@ -0,0 +1,8 @@
[addressbooks]
[[forward]]
path = /home/user/who/likes/forward/slashes/a/lot
[general]
default_action=list