1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-27 13:39:46 +01:00
This commit is contained in:
Robert Helgesson 2019-07-10 01:52:36 +02:00
parent e8abc2ac53
commit f8ec686211
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
6 changed files with 129 additions and 129 deletions

View file

@ -11,6 +11,7 @@ let
path = mkOption { path = mkOption {
type = types.str; type = types.str;
default = "${cfg.basePath}/${name}"; default = "${cfg.basePath}/${name}";
defaultText = "accounts.contact.basePath/name";
description = "The path of the storage."; description = "The path of the storage.";
}; };
@ -46,7 +47,7 @@ let
url = mkOption { url = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
description = "The url of the storage."; description = "The URL of the storage.";
}; };
userName = mkOption { userName = mkOption {
@ -55,23 +56,21 @@ let
description = "User name for authentication."; description = "User name for authentication.";
}; };
userNameCommand = mkOption { # userNameCommand = mkOption {
type = types.nullOr (types.listOf types.str); # type = types.nullOr (types.listOf types.str);
default = null; # default = null;
example = [ "~/get-username.sh" ]; # example = [ "~/get-username.sh" ];
description = '' # description = ''
A command that prints the user name to standard # A command that prints the user name to standard output.
output. # '';
''; # };
};
passwordCommand = mkOption { passwordCommand = mkOption {
type = types.nullOr (types.listOf types.str); type = types.nullOr (types.listOf types.str);
default = null; default = null;
example = [ "pass" "caldav" ]; example = [ "pass" "caldav" ];
description = '' description = ''
A command that prints the password to standard A command that prints the password to standard output.
output.
''; '';
}; };
}; };
@ -88,7 +87,6 @@ let
''; '';
}; };
primary = mkOption { primary = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
@ -101,14 +99,13 @@ let
primaryCollection = mkOption { primaryCollection = mkOption {
type = types.str; type = types.str;
description = '' description = ''
The primary collection of the account. Required when an account has The primary collection of the account. Required when an
multiple collections. account has multiple collections.
''; '';
}; };
local = mkOption { local = mkOption {
type = types.nullOr (localModule name); type = types.nullOr (localModule name);
default = null; default = null;
description = '' description = ''
Local configuration for the calendar. Local configuration for the calendar.
@ -117,7 +114,6 @@ let
remote = mkOption { remote = mkOption {
type = types.nullOr remoteModule; type = types.nullOr remoteModule;
default = null; default = null;
description = '' description = ''
Remote configuration for the calendar. Remote configuration for the calendar.
@ -125,12 +121,9 @@ let
}; };
}; };
config = mkMerge [ config = {
{
name = name; name = name;
khal.type = mkOptionDefault null; };
}
];
}; };
in in
@ -139,10 +132,14 @@ in
options.accounts.calendar = { options.accounts.calendar = {
basePath = mkOption { basePath = mkOption {
type = types.str; type = types.str;
default = "${config.home.homeDirectory}/.calendars/"; apply = p:
defaultText = "$HOME/.calendars"; if hasPrefix "/" p
then p
else "${config.home.homeDirectory}/${p}";
description = '' 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; assertion = length primaries <= 1;
message = message =
"Must have at most one primary calendar accounts but found " "Must have at most one primary calendar account but found "
+ toString (length primaries) + toString (length primaries)
+ ", namely " + ", namely "
+ concatStringsSep ", " primaries; + concatStringsSep ", " primaries;

View file

@ -11,6 +11,7 @@ let
path = mkOption { path = mkOption {
type = types.str; type = types.str;
default = "${cfg.basePath}/${name}"; default = "${cfg.basePath}/${name}";
defaultText = "accounts.contact.basePath/name";
description = "The path of the storage."; description = "The path of the storage.";
}; };
@ -46,7 +47,7 @@ let
url = mkOption { url = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
description = "The url of the storage."; description = "The URL of the storage.";
}; };
userName = mkOption { userName = mkOption {
@ -55,23 +56,21 @@ let
description = "User name for authentication."; description = "User name for authentication.";
}; };
userNameCommand = mkOption { # userNameCommand = mkOption {
type = types.nullOr (types.listOf types.str); # type = types.nullOr (types.listOf types.str);
default = null; # default = null;
example = [ "~/get-username.sh" ]; # example = [ "~/get-username.sh" ];
description = '' # description = ''
A command that prints the user name to standard # A command that prints the user name to standard output.
output. # '';
''; # };
};
passwordCommand = mkOption { passwordCommand = mkOption {
type = types.nullOr (types.listOf types.str); type = types.nullOr (types.listOf types.str);
default = null; default = null;
example = [ "pass" "caldav" ]; example = [ "pass" "caldav" ];
description = '' description = ''
A command that prints the password to standard A command that prints the password to standard output.
output.
''; '';
}; };
}; };
@ -105,11 +104,9 @@ let
}; };
}; };
config = mkMerge [ config = {
{
name = name; name = name;
} };
];
}; };
in in
@ -118,10 +115,14 @@ in
options.accounts.contact = { options.accounts.contact = {
basePath = mkOption { basePath = mkOption {
type = types.str; type = types.str;
default = "${config.home.homeDirectory}/.contacts/"; apply = p:
defaultText = "$HOME/.contacts"; if hasPrefix "/" p
then p
else "${config.home.homeDirectory}/${p}";
description = '' 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."; description = "List of contacts.";
}; };
}; };
config = mkIf (cfg.accounts != {}) {
};
} }

View file

@ -8,19 +8,10 @@ with lib;
readOnly = mkOption { readOnly = mkOption {
type = types.bool; type = types.bool;
default = false;
description = '' description = ''
Keep khal from making any changes to this account. 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.
'';
}; };
}; };
} }

View file

@ -6,7 +6,18 @@ with lib;
options.khal = { options.khal = {
type = mkOption { type = mkOption {
type = types.nullOr (types.enum [ "calendar" "discover"]); type = types.nullOr (types.enum [ "calendar" "discover"]);
default = null;
description = '' 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.
''; '';
}; };
}; };

View file

@ -7,17 +7,30 @@ let
cfg = config.programs.khal; cfg = config.programs.khal;
khalCalendarAccounts = filterAttrs (_: a: a.khal.enable) khalCalendarAccounts =
(config.accounts.calendar.accounts); filterAttrs (_: a: a.khal.enable) config.accounts.calendar.accounts;
khalContactAccounts = mapAttrs (_: v: v // {type = "birthdays";}) khalContactAccounts =
(filterAttrs (_: a: a.khal.enable) mapAttrs (_: v: v // { type = "birthdays"; })
(config.accounts.contact.accounts)); (filterAttrs (_: a: a.khal.enable) config.accounts.contact.accounts);
khalAccounts = khalCalendarAccounts // khalContactAccounts; khalAccounts = khalCalendarAccounts // khalContactAccounts;
primaryAccount = findSingle (a: a.primary) null null primaryAccount =
findSingle (a: a.primary) null null
(mapAttrsToList (n: v: v // {name= n;}) khalAccounts); (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 in
{ {
@ -32,16 +45,7 @@ in
[ [
"[calendars]" "[calendars]"
] ]
++ (mapAttrsToList (name: value: concatStringsSep "\n" ++ mapAttrsToList genCalendarStr khalAccounts
([
''[[${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"]
)
) khalAccounts)
++ ++
[ [
(generators.toINI {} { (generators.toINI {} {

View file

@ -21,14 +21,18 @@ in
}; };
conflictResolution = mkOption { 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; default = null;
description = '' description = ''
What to do in case of a conflict between the storages. What to do in case of a conflict between the storages. Either
Either <literal>"remote wins"</literal> <literal>remote wins</literal> or
or <literal>"local wins"</literal> <literal>local wins</literal> or
or a list that contains a command to run. a list that contains a command to run. By default, an error
By default, an error message is printed. message is printed.
''; '';
}; };
@ -38,8 +42,9 @@ in
description = '' description = ''
What should happen if synchronization in one direction What should happen if synchronization in one direction
is impossible due to one storage being read-only. is impossible due to one storage being read-only.
Defaults to <literal>"revert"</literal>.</para> Defaults to <literal>revert</literal>.
<para>See </para><para>
See
<link xlink:href="https://vdirsyncer.pimutils.org/en/stable/config.html#pair-section"/> <link xlink:href="https://vdirsyncer.pimutils.org/en/stable/config.html#pair-section"/>
for more information. for more information.
''; '';
@ -50,8 +55,8 @@ in
default = []; default = [];
example = [ "color" "displayname" ]; example = [ "color" "displayname" ];
description = '' description = ''
Metadata keys that should be synchronized Metadata keys that should be synchronized when vdirsyncer
when vdirsyncer metasync is executed. metasync is executed.
''; '';
}; };
@ -69,12 +74,11 @@ in
}; };
}; };
}); });
default = null; default = null;
description = '' description = ''
A time range to synchronize. start and end A time range to synchronize. start and end can be any Python
can be any Python expression that returns expression that returns a <literal>datetime.datetime</literal>
a <literal>datetime.datetime</literal> object. object.
''; '';
example = { example = {
start = "datetime.now() - timedelta(days=365)"; start = "datetime.now() - timedelta(days=365)";
@ -86,10 +90,9 @@ in
type = types.nullOr (types.listOf types.str); type = types.nullOr (types.listOf types.str);
default = null; default = null;
description = '' description = ''
Kinds of items to show. The default is to Kinds of items to show. The default is to show everything.
show everything. This depends on particular This depends on particular features of the server, the results
features of the server, the results are not are not validated.
validated.
''; '';
}; };
@ -103,9 +106,9 @@ in
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
description = '' description = ''
Optional. SHA1 or MD5 fingerprint of the expected server certificate.</para> Optional. SHA1 or MD5 fingerprint of the expected server certificate.
</para><para>
<para>See See
<link xlink:href="https://vdirsyncer.pimutils.org/en/stable/ssl-tutorial.html#ssl-tutorial"/> <link xlink:href="https://vdirsyncer.pimutils.org/en/stable/ssl-tutorial.html#ssl-tutorial"/>
for more information. for more information.
''; '';
@ -115,7 +118,7 @@ in
type = types.nullOr (types.enum ["basic" "digest" "guess"]); type = types.nullOr (types.enum ["basic" "digest" "guess"]);
default = null; default = null;
description = '' 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)); type = types.nullOr (types.either types.str (types.listOf types.str));
default = null; default = null;
description = '' description = ''
Either a path to a certificate with a client certificate Either a path to a certificate with a client certificate and
and the key or a list of paths to the files with them. the key or a list of paths to the files with them.
''; '';
}; };
@ -132,8 +135,8 @@ in
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
description = '' description = ''
The user agent to report to the server. The user agent to report to the server. Defaults to
Defaults to <literal>"vdirsyncer"</literal>. <literal>vdirsyncer</literal>.
''; '';
}; };
@ -153,8 +156,7 @@ in
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
description = '' description = ''
A file path where access tokens A file path where access tokens are stored.
are stored.
''; '';
}; };
@ -165,10 +167,8 @@ in
description = '' description = ''
A command that prints the OAuth credentials to standard A command that prints the OAuth credentials to standard
output. output.
</para><para>
OAuth credentials, obtained from the Google API Manager.</para> See
<para> See
<link xlink:href="https://vdirsyncer.pimutils.org/en/stable/config.html#google"/> <link xlink:href="https://vdirsyncer.pimutils.org/en/stable/config.html#google"/>
for more information. for more information.
''; '';
@ -181,10 +181,8 @@ in
description = '' description = ''
A command that prints the OAuth credentials to standard A command that prints the OAuth credentials to standard
output. output.
</para><para>
OAuth credentials, obtained from the Google API Manager.</para> See
<para> See
<link xlink:href="https://vdirsyncer.pimutils.org/en/stable/config.html#google"/> <link xlink:href="https://vdirsyncer.pimutils.org/en/stable/config.html#google"/>
for more information. for more information.
''; '';