wip
This commit is contained in:
parent
e8abc2ac53
commit
f8ec686211
|
@ -11,6 +11,7 @@ let
|
|||
path = mkOption {
|
||||
type = types.str;
|
||||
default = "${cfg.basePath}/${name}";
|
||||
defaultText = "‹accounts.contact.basePath›/‹name›";
|
||||
description = "The path of the storage.";
|
||||
};
|
||||
|
||||
|
@ -46,7 +47,7 @@ let
|
|||
url = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = "The url of the storage.";
|
||||
description = "The URL of the storage.";
|
||||
};
|
||||
|
||||
userName = mkOption {
|
||||
|
@ -55,23 +56,21 @@ let
|
|||
description = "User name for authentication.";
|
||||
};
|
||||
|
||||
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.
|
||||
'';
|
||||
};
|
||||
# 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" ];
|
||||
description = ''
|
||||
A command that prints the password to standard
|
||||
output.
|
||||
A command that prints the password to standard output.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
@ -88,7 +87,6 @@ let
|
|||
'';
|
||||
};
|
||||
|
||||
|
||||
primary = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
|
@ -101,14 +99,13 @@ let
|
|||
primaryCollection = mkOption {
|
||||
type = types.str;
|
||||
description = ''
|
||||
The primary collection of the account. Required when an account has
|
||||
multiple collections.
|
||||
The primary collection of the account. Required when an
|
||||
account has multiple collections.
|
||||
'';
|
||||
};
|
||||
|
||||
local = mkOption {
|
||||
type = types.nullOr (localModule name);
|
||||
|
||||
default = null;
|
||||
description = ''
|
||||
Local configuration for the calendar.
|
||||
|
@ -117,7 +114,6 @@ let
|
|||
|
||||
remote = mkOption {
|
||||
type = types.nullOr remoteModule;
|
||||
|
||||
default = null;
|
||||
description = ''
|
||||
Remote configuration for the calendar.
|
||||
|
@ -125,12 +121,9 @@ let
|
|||
};
|
||||
};
|
||||
|
||||
config = mkMerge [
|
||||
{
|
||||
name = name;
|
||||
khal.type = mkOptionDefault null;
|
||||
}
|
||||
];
|
||||
config = {
|
||||
name = name;
|
||||
};
|
||||
};
|
||||
|
||||
in
|
||||
|
@ -139,10 +132,14 @@ in
|
|||
options.accounts.calendar = {
|
||||
basePath = mkOption {
|
||||
type = types.str;
|
||||
default = "${config.home.homeDirectory}/.calendars/";
|
||||
defaultText = "$HOME/.calendars";
|
||||
apply = p:
|
||||
if hasPrefix "/" p
|
||||
then p
|
||||
else "${config.home.homeDirectory}/${p}";
|
||||
description = ''
|
||||
The base directory in which to save calendars.
|
||||
The base directory in which to save calendars. May be a
|
||||
relative path, in which case it is relative the home
|
||||
directory.
|
||||
'';
|
||||
};
|
||||
|
||||
|
@ -168,7 +165,7 @@ in
|
|||
[{
|
||||
assertion = length primaries <= 1;
|
||||
message =
|
||||
"Must have at most one primary calendar accounts but found "
|
||||
"Must have at most one primary calendar account but found "
|
||||
+ toString (length primaries)
|
||||
+ ", namely "
|
||||
+ concatStringsSep ", " primaries;
|
||||
|
|
|
@ -11,6 +11,7 @@ let
|
|||
path = mkOption {
|
||||
type = types.str;
|
||||
default = "${cfg.basePath}/${name}";
|
||||
defaultText = "‹accounts.contact.basePath›/‹name›";
|
||||
description = "The path of the storage.";
|
||||
};
|
||||
|
||||
|
@ -46,7 +47,7 @@ let
|
|||
url = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = "The url of the storage.";
|
||||
description = "The URL of the storage.";
|
||||
};
|
||||
|
||||
userName = mkOption {
|
||||
|
@ -55,23 +56,21 @@ let
|
|||
description = "User name for authentication.";
|
||||
};
|
||||
|
||||
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.
|
||||
'';
|
||||
};
|
||||
# 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" ];
|
||||
description = ''
|
||||
A command that prints the password to standard
|
||||
output.
|
||||
A command that prints the password to standard output.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
@ -105,11 +104,9 @@ let
|
|||
};
|
||||
};
|
||||
|
||||
config = mkMerge [
|
||||
{
|
||||
name = name;
|
||||
}
|
||||
];
|
||||
config = {
|
||||
name = name;
|
||||
};
|
||||
};
|
||||
|
||||
in
|
||||
|
@ -118,10 +115,14 @@ in
|
|||
options.accounts.contact = {
|
||||
basePath = mkOption {
|
||||
type = types.str;
|
||||
default = "${config.home.homeDirectory}/.contacts/";
|
||||
defaultText = "$HOME/.contacts";
|
||||
apply = p:
|
||||
if hasPrefix "/" p
|
||||
then p
|
||||
else "${config.home.homeDirectory}/${p}";
|
||||
description = ''
|
||||
The base directory in which to save contacts.
|
||||
The base directory in which to save contacts. May be a
|
||||
relative path, in which case it is relative the home
|
||||
directory.
|
||||
'';
|
||||
};
|
||||
|
||||
|
@ -135,6 +136,4 @@ in
|
|||
description = "List of contacts.";
|
||||
};
|
||||
};
|
||||
config = mkIf (cfg.accounts != {}) {
|
||||
};
|
||||
}
|
||||
|
|
|
@ -8,19 +8,10 @@ with lib;
|
|||
|
||||
readOnly = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Keep khal from making any changes to this account.
|
||||
'';
|
||||
default = false;
|
||||
};
|
||||
|
||||
glob = mkOption {
|
||||
type = types.str;
|
||||
default = "*";
|
||||
description = ''
|
||||
The glob expansion to be searched for events or birthdays when type
|
||||
is set to discover.
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -6,7 +6,18 @@ with lib;
|
|||
options.khal = {
|
||||
type = mkOption {
|
||||
type = types.nullOr (types.enum [ "calendar" "discover"]);
|
||||
default = null;
|
||||
description = ''
|
||||
There is no description of this option.
|
||||
'';
|
||||
};
|
||||
|
||||
glob = mkOption {
|
||||
type = types.str;
|
||||
default = "*";
|
||||
description = ''
|
||||
The glob expansion to be searched for events or birthdays when
|
||||
type is set to discover.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
|
|
@ -7,17 +7,30 @@ let
|
|||
|
||||
cfg = config.programs.khal;
|
||||
|
||||
khalCalendarAccounts = filterAttrs (_: a: a.khal.enable)
|
||||
(config.accounts.calendar.accounts);
|
||||
khalCalendarAccounts =
|
||||
filterAttrs (_: a: a.khal.enable) config.accounts.calendar.accounts;
|
||||
|
||||
khalContactAccounts = mapAttrs (_: v: v // {type = "birthdays";})
|
||||
(filterAttrs (_: a: a.khal.enable)
|
||||
(config.accounts.contact.accounts));
|
||||
khalContactAccounts =
|
||||
mapAttrs (_: v: v // { type = "birthdays"; })
|
||||
(filterAttrs (_: a: a.khal.enable) config.accounts.contact.accounts);
|
||||
|
||||
khalAccounts = khalCalendarAccounts // khalContactAccounts;
|
||||
|
||||
primaryAccount = findSingle (a: a.primary) null null
|
||||
primaryAccount =
|
||||
findSingle (a: a.primary) null null
|
||||
(mapAttrsToList (n: v: v // {name= n;}) khalAccounts);
|
||||
|
||||
genCalendarStr = name: value:
|
||||
concatStringsSep "\n" (
|
||||
[
|
||||
"[[${name}]]"
|
||||
"path = ${value.local.path + "/" + (optionalString (value.khal.type == "discover") value.khal.glob)}"
|
||||
]
|
||||
++ optional (value.khal.readOnly) "readonly = True"
|
||||
++ optional (!isNull value.khal.type) "type = ${value.khal.type}"
|
||||
++ ["\n"]
|
||||
);
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
|
@ -29,36 +42,27 @@ in
|
|||
home.packages = [ pkgs.khal ];
|
||||
|
||||
xdg.configFile."khal/config".text = concatStringsSep "\n" (
|
||||
[
|
||||
"[calendars]"
|
||||
]
|
||||
++ (mapAttrsToList (name: value: concatStringsSep "\n"
|
||||
([
|
||||
''[[${name}]]''
|
||||
''path = ${value.local.path + "/" + (optionalString (value.khal.type == "discover") value.khal.glob)}''
|
||||
[
|
||||
"[calendars]"
|
||||
]
|
||||
++ optional (value.khal.readOnly) "readonly = True"
|
||||
++ optional (!isNull value.khal.type) "type = ${value.khal.type}"
|
||||
++ ["\n"]
|
||||
)
|
||||
) khalAccounts)
|
||||
++
|
||||
[
|
||||
(generators.toINI {} {
|
||||
default = optionalAttrs (!isNull primaryAccount) {
|
||||
default_calendar = if isNull primaryAccount.primaryCollection then primaryAccount.name else primaryAccount.primaryCollection;
|
||||
};
|
||||
++ mapAttrsToList genCalendarStr khalAccounts
|
||||
++
|
||||
[
|
||||
(generators.toINI {} {
|
||||
default = optionalAttrs (!isNull primaryAccount) {
|
||||
default_calendar = if isNull primaryAccount.primaryCollection then primaryAccount.name else primaryAccount.primaryCollection;
|
||||
};
|
||||
|
||||
locale = {
|
||||
timeformat = "%H:%M";
|
||||
dateformat = "%Y-%m-%d";
|
||||
longdateformat = "%Y-%m-%d";
|
||||
datetimeformat = "%Y-%m-%d %H:%M";
|
||||
longdatetimeformat = "%Y-%m-%d %H:%M";
|
||||
weeknumbers = "right";
|
||||
};
|
||||
})
|
||||
]
|
||||
locale = {
|
||||
timeformat = "%H:%M";
|
||||
dateformat = "%Y-%m-%d";
|
||||
longdateformat = "%Y-%m-%d";
|
||||
datetimeformat = "%Y-%m-%d %H:%M";
|
||||
longdatetimeformat = "%Y-%m-%d %H:%M";
|
||||
weeknumbers = "right";
|
||||
};
|
||||
})
|
||||
]
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -21,14 +21,18 @@ in
|
|||
};
|
||||
|
||||
conflictResolution = mkOption {
|
||||
type = types.nullOr (types.either (types.enum ["remote wins" "local wins"]) (types.listOf types.str));
|
||||
type =
|
||||
types.nullOr
|
||||
(types.either
|
||||
(types.enum ["remote wins" "local wins"])
|
||||
(types.listOf types.str));
|
||||
default = null;
|
||||
description = ''
|
||||
What to do in case of a conflict between the storages.
|
||||
Either <literal>"remote wins"</literal>
|
||||
or <literal>"local wins"</literal>
|
||||
or a list that contains a command to run.
|
||||
By default, an error message is printed.
|
||||
What to do in case of a conflict between the storages. Either
|
||||
<literal>remote wins</literal> or
|
||||
<literal>local wins</literal> or
|
||||
a list that contains a command to run. By default, an error
|
||||
message is printed.
|
||||
'';
|
||||
};
|
||||
|
||||
|
@ -38,8 +42,9 @@ in
|
|||
description = ''
|
||||
What should happen if synchronization in one direction
|
||||
is impossible due to one storage being read-only.
|
||||
Defaults to <literal>"revert"</literal>.</para>
|
||||
<para>See
|
||||
Defaults to <literal>revert</literal>.
|
||||
</para><para>
|
||||
See
|
||||
<link xlink:href="https://vdirsyncer.pimutils.org/en/stable/config.html#pair-section"/>
|
||||
for more information.
|
||||
'';
|
||||
|
@ -50,8 +55,8 @@ in
|
|||
default = [];
|
||||
example = [ "color" "displayname" ];
|
||||
description = ''
|
||||
Metadata keys that should be synchronized
|
||||
when vdirsyncer metasync is executed.
|
||||
Metadata keys that should be synchronized when vdirsyncer
|
||||
metasync is executed.
|
||||
'';
|
||||
};
|
||||
|
||||
|
@ -69,12 +74,11 @@ in
|
|||
};
|
||||
};
|
||||
});
|
||||
|
||||
default = null;
|
||||
description = ''
|
||||
A time range to synchronize. start and end
|
||||
can be any Python expression that returns
|
||||
a <literal>datetime.datetime</literal> object.
|
||||
A time range to synchronize. start and end can be any Python
|
||||
expression that returns a <literal>datetime.datetime</literal>
|
||||
object.
|
||||
'';
|
||||
example = {
|
||||
start = "datetime.now() - timedelta(days=365)";
|
||||
|
@ -86,10 +90,9 @@ in
|
|||
type = types.nullOr (types.listOf types.str);
|
||||
default = null;
|
||||
description = ''
|
||||
Kinds of items to show. The default is to
|
||||
show everything. This depends on particular
|
||||
features of the server, the results are not
|
||||
validated.
|
||||
Kinds of items to show. The default is to show everything.
|
||||
This depends on particular features of the server, the results
|
||||
are not validated.
|
||||
'';
|
||||
};
|
||||
|
||||
|
@ -103,9 +106,9 @@ in
|
|||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = ''
|
||||
Optional. SHA1 or MD5 fingerprint of the expected server certificate.</para>
|
||||
|
||||
<para>See
|
||||
Optional. SHA1 or MD5 fingerprint of the expected server certificate.
|
||||
</para><para>
|
||||
See
|
||||
<link xlink:href="https://vdirsyncer.pimutils.org/en/stable/ssl-tutorial.html#ssl-tutorial"/>
|
||||
for more information.
|
||||
'';
|
||||
|
@ -115,7 +118,7 @@ in
|
|||
type = types.nullOr (types.enum ["basic" "digest" "guess"]);
|
||||
default = null;
|
||||
description = ''
|
||||
Authentication settings. The default is <literal>"basic"</literal>.
|
||||
Authentication settings. The default is <literal>basic</literal>.
|
||||
'';
|
||||
};
|
||||
|
||||
|
@ -123,8 +126,8 @@ in
|
|||
type = types.nullOr (types.either types.str (types.listOf types.str));
|
||||
default = null;
|
||||
description = ''
|
||||
Either a path to a certificate with a client certificate
|
||||
and the key or a list of paths to the files with them.
|
||||
Either a path to a certificate with a client certificate and
|
||||
the key or a list of paths to the files with them.
|
||||
'';
|
||||
};
|
||||
|
||||
|
@ -132,8 +135,8 @@ in
|
|||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = ''
|
||||
The user agent to report to the server.
|
||||
Defaults to <literal>"vdirsyncer"</literal>.
|
||||
The user agent to report to the server. Defaults to
|
||||
<literal>vdirsyncer</literal>.
|
||||
'';
|
||||
};
|
||||
|
||||
|
@ -153,8 +156,7 @@ in
|
|||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = ''
|
||||
A file path where access tokens
|
||||
are stored.
|
||||
A file path where access tokens are stored.
|
||||
'';
|
||||
};
|
||||
|
||||
|
@ -165,10 +167,8 @@ in
|
|||
description = ''
|
||||
A command that prints the OAuth credentials to standard
|
||||
output.
|
||||
|
||||
OAuth credentials, obtained from the Google API Manager.</para>
|
||||
|
||||
<para> See
|
||||
</para><para>
|
||||
See
|
||||
<link xlink:href="https://vdirsyncer.pimutils.org/en/stable/config.html#google"/>
|
||||
for more information.
|
||||
'';
|
||||
|
@ -181,10 +181,8 @@ in
|
|||
description = ''
|
||||
A command that prints the OAuth credentials to standard
|
||||
output.
|
||||
|
||||
OAuth credentials, obtained from the Google API Manager.</para>
|
||||
|
||||
<para> See
|
||||
</para><para>
|
||||
See
|
||||
<link xlink:href="https://vdirsyncer.pimutils.org/en/stable/config.html#google"/>
|
||||
for more information.
|
||||
'';
|
||||
|
|
Loading…
Reference in a new issue