2023-06-12 23:21:24 +02:00
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
|
|
cfg = config.accounts.contact;
|
|
|
|
|
|
|
|
|
|
localModule = name:
|
|
|
|
|
types.submodule {
|
|
|
|
|
options = {
|
|
|
|
|
path = mkOption {
|
|
|
|
|
type = types.str;
|
|
|
|
|
default = "${cfg.basePath}/${name}";
|
|
|
|
|
defaultText = "‹accounts.contact.basePath›/‹name›";
|
2023-07-01 01:30:13 +02:00
|
|
|
|
description = lib.mdDoc "The path of the storage.";
|
2023-06-12 23:21:24 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
type = mkOption {
|
|
|
|
|
type = types.enum [ "filesystem" "singlefile" ];
|
2023-07-01 01:30:13 +02:00
|
|
|
|
description = lib.mdDoc "The type of the storage.";
|
2023-06-12 23:21:24 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
fileExt = mkOption {
|
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
|
default = null;
|
2023-07-01 01:30:13 +02:00
|
|
|
|
description = lib.mdDoc "The file extension to use.";
|
2023-06-12 23:21:24 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
encoding = mkOption {
|
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
|
default = null;
|
2023-07-01 01:30:13 +02:00
|
|
|
|
description = lib.mdDoc ''
|
2023-06-12 23:21:24 +02:00
|
|
|
|
File encoding for items, both content and file name.
|
|
|
|
|
Defaults to UTF-8.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
remoteModule = types.submodule {
|
|
|
|
|
options = {
|
|
|
|
|
type = mkOption {
|
|
|
|
|
type = types.enum [ "carddav" "http" "google_contacts" ];
|
2023-07-01 01:30:13 +02:00
|
|
|
|
description = lib.mdDoc "The type of the storage.";
|
2023-06-12 23:21:24 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
url = mkOption {
|
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
|
default = null;
|
2023-07-01 01:30:13 +02:00
|
|
|
|
description = lib.mdDoc "The URL of the storage.";
|
2023-06-12 23:21:24 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
userName = mkOption {
|
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
|
default = null;
|
2023-07-01 01:30:13 +02:00
|
|
|
|
description = lib.mdDoc "User name for authentication.";
|
2023-06-12 23:21:24 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# userNameCommand = mkOption {
|
|
|
|
|
# type = types.nullOr (types.listOf types.str);
|
|
|
|
|
# default = null;
|
|
|
|
|
# example = [ "~/get-username.sh" ];
|
|
|
|
|
# description = ''
|
|
|
|
|
# A command that prints the user name to standard output.
|
|
|
|
|
# '';
|
|
|
|
|
# };
|
|
|
|
|
|
|
|
|
|
passwordCommand = mkOption {
|
|
|
|
|
type = types.nullOr (types.listOf types.str);
|
|
|
|
|
default = null;
|
|
|
|
|
example = [ "pass" "caldav" ];
|
2023-07-01 01:30:13 +02:00
|
|
|
|
description = lib.mdDoc ''
|
2023-06-12 23:21:24 +02:00
|
|
|
|
A command that prints the password to standard output.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
contactOpts = { name, config, ... }: {
|
|
|
|
|
options = {
|
|
|
|
|
name = mkOption {
|
|
|
|
|
type = types.str;
|
|
|
|
|
readOnly = true;
|
2023-07-01 01:30:13 +02:00
|
|
|
|
description = lib.mdDoc ''
|
2023-06-12 23:21:24 +02:00
|
|
|
|
Unique identifier of the contact account. This is set to the
|
|
|
|
|
attribute name of the contact configuration.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
local = mkOption {
|
|
|
|
|
type = types.nullOr (localModule name);
|
|
|
|
|
default = null;
|
2023-07-01 01:30:13 +02:00
|
|
|
|
description = lib.mdDoc ''
|
2023-06-12 23:21:24 +02:00
|
|
|
|
Local configuration for the contacts.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
remote = mkOption {
|
|
|
|
|
type = types.nullOr remoteModule;
|
|
|
|
|
default = null;
|
2023-07-01 01:30:13 +02:00
|
|
|
|
description = lib.mdDoc ''
|
2023-06-12 23:21:24 +02:00
|
|
|
|
Remote configuration for the contacts.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
config = { name = name; };
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
in {
|
|
|
|
|
options.accounts.contact = {
|
|
|
|
|
basePath = mkOption {
|
|
|
|
|
type = types.str;
|
|
|
|
|
apply = p:
|
|
|
|
|
if hasPrefix "/" p then p else "${config.home.homeDirectory}/${p}";
|
2023-07-01 01:30:13 +02:00
|
|
|
|
description = lib.mdDoc ''
|
2023-06-12 23:21:24 +02:00
|
|
|
|
The base directory in which to save contacts. May be a
|
|
|
|
|
relative path, in which case it is relative the home
|
|
|
|
|
directory.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
accounts = mkOption {
|
|
|
|
|
type = types.attrsOf (types.submodule [
|
|
|
|
|
contactOpts
|
|
|
|
|
(import ../programs/vdirsyncer-accounts.nix)
|
|
|
|
|
(import ../programs/khal-accounts.nix)
|
|
|
|
|
]);
|
|
|
|
|
default = { };
|
2023-07-01 01:30:13 +02:00
|
|
|
|
description = lib.mdDoc "List of contacts.";
|
2023-06-12 23:21:24 +02:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}
|