mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 03:29:45 +01:00
vdirsyncer: add urlCommand and userNameCommand options
This commit is contained in:
parent
1c2acec999
commit
19b87b9ae6
3 changed files with 49 additions and 31 deletions
|
@ -58,15 +58,6 @@ 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.
|
||||
# '';
|
||||
# };
|
||||
|
||||
passwordCommand = mkOption {
|
||||
type = types.nullOr (types.listOf types.str);
|
||||
default = null;
|
||||
|
|
|
@ -10,6 +10,20 @@ in {
|
|||
options.vdirsyncer = {
|
||||
enable = mkEnableOption "synchronization using vdirsyncer";
|
||||
|
||||
urlCommand = mkOption {
|
||||
type = types.nullOr (types.listOf types.str);
|
||||
default = null;
|
||||
example = [ "~/get-url.sh" ];
|
||||
description = "A command that prints the URL of the storage.";
|
||||
};
|
||||
|
||||
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.";
|
||||
};
|
||||
|
||||
collections = mkOption {
|
||||
type = types.nullOr (types.listOf collection);
|
||||
default = null;
|
||||
|
|
|
@ -32,16 +32,14 @@ let
|
|||
});
|
||||
|
||||
remoteStorage = a:
|
||||
filterAttrs (_: v: v != null) ((getAttrs [
|
||||
"type"
|
||||
"url"
|
||||
"userName"
|
||||
#"userNameCommand"
|
||||
"passwordCommand"
|
||||
] a.remote) // (if a.vdirsyncer == null then
|
||||
filterAttrs (_: v: v != null)
|
||||
((getAttrs [ "type" "url" "userName" "passwordCommand" ] a.remote)
|
||||
// (if a.vdirsyncer == null then
|
||||
{ }
|
||||
else
|
||||
getAttrs [
|
||||
"urlCommand"
|
||||
"userNameCommand"
|
||||
"itemTypes"
|
||||
"verify"
|
||||
"verifyFingerprint"
|
||||
|
@ -77,6 +75,8 @@ let
|
|||
''post_hook = "${v}"''
|
||||
else if (n == "url") then
|
||||
''url = "${v}"''
|
||||
else if (n == "urlCommand") then
|
||||
"url.fetch = ${listString (map wrap ([ "command" ] ++ v))}"
|
||||
else if (n == "timeRange") then ''
|
||||
start_date = "${v.start}"
|
||||
end_date = "${v.end}"'' else if (n == "itemTypes") then
|
||||
|
@ -196,6 +196,9 @@ in {
|
|||
config = mkIf cfg.enable {
|
||||
assertions = let
|
||||
|
||||
mutuallyExclusiveOptions =
|
||||
[ [ "url" "urlCommand" ] [ "userName" "userNameCommand" ] ];
|
||||
|
||||
requiredOptions = t:
|
||||
if (t == "caldav" || t == "carddav" || t == "http") then
|
||||
[ "url" ]
|
||||
|
@ -213,6 +216,7 @@ in {
|
|||
|
||||
allowedOptions = let
|
||||
remoteOptions = [
|
||||
"urlCommand"
|
||||
"userName"
|
||||
"userNameCommand"
|
||||
"password"
|
||||
|
@ -264,7 +268,16 @@ in {
|
|||
Storage ${n} is of type ${v.type}, but required
|
||||
option ${a} is not set.
|
||||
'';
|
||||
}]) required)) (removeAttrs v [ "type" "_module" ]);
|
||||
}]) required) ++ map (attrs:
|
||||
let
|
||||
defined = attrNames (filterAttrs (n: v: v != null)
|
||||
(genAttrs attrs (a: v.${a} or null)));
|
||||
in {
|
||||
assertion = length defined <= 1;
|
||||
message = "Storage ${n} has mutually exclusive options: ${
|
||||
concatStringsSep ", " defined
|
||||
}";
|
||||
}) mutuallyExclusiveOptions) (removeAttrs v [ "type" "_module" ]);
|
||||
|
||||
storageAssertions = flatten (mapAttrsToList assertStorage localStorages)
|
||||
++ flatten (mapAttrsToList assertStorage remoteStorages);
|
||||
|
|
Loading…
Reference in a new issue