Add configurations for individual providers
This commit is contained in:
parent
29f60a3da9
commit
e8173f7566
1 changed files with 54 additions and 2 deletions
|
@ -4,10 +4,17 @@ let
|
|||
targetName = "rclone";
|
||||
|
||||
mkProvider =
|
||||
{ secretLoader ? ({ ... }: ""), envLoader ? ({ ... }: { }), options ? {}, ... }: {
|
||||
{
|
||||
secretLoader ? ({ ... }: ""),
|
||||
envLoader ? ({ ... }: { }),
|
||||
configLoader ? ({ ... }: { }),
|
||||
options ? {},
|
||||
...
|
||||
}: {
|
||||
inherit
|
||||
secretLoader
|
||||
envLoader
|
||||
configLoader
|
||||
options
|
||||
;
|
||||
};
|
||||
|
@ -24,8 +31,37 @@ let
|
|||
inherit default;
|
||||
};
|
||||
|
||||
mkWebdavOptions = { vendorName }: {
|
||||
username = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "The name of the user to log in to ${vendorName}.";
|
||||
};
|
||||
|
||||
password = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
description = "The password for logging in to ${vendorName}.";
|
||||
};
|
||||
|
||||
passwordFile = lib.mkOption {
|
||||
type = lib.types.nullOr (lib.types.either lib.types.path lib.types.str);
|
||||
description = "A path to a file to read the password from for logging in to ${vendorName}.";
|
||||
};
|
||||
};
|
||||
|
||||
mkOwncloudOptions =
|
||||
{ vendorName ? "Nextcloud" }: (mkWebdavOptions { inherit vendorName; }) // {
|
||||
baseUrl = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "The base URL of the ${vendorName} server.";
|
||||
};
|
||||
};
|
||||
|
||||
syncProviders = {
|
||||
nextcloud = mkProvider {};
|
||||
nextcloud = mkProvider {
|
||||
options = lib.types.submodule (
|
||||
(mkOwncloudOptions { }));
|
||||
};
|
||||
|
||||
proton = mkProvider {};
|
||||
manual = mkProvider {};
|
||||
};
|
||||
|
@ -45,6 +81,15 @@ let
|
|||
default = true;
|
||||
};
|
||||
|
||||
providerOptions = lib.mkOption {
|
||||
description = "The options of the sync";
|
||||
type = lib.types.oneOf [
|
||||
(builtins.map
|
||||
(provider: provider.options)
|
||||
syncProviders)
|
||||
];
|
||||
};
|
||||
|
||||
systemdDependencies = mkSystemdDependencyOption {
|
||||
default = cfg.systemdDependencies;
|
||||
};
|
||||
|
@ -60,11 +105,18 @@ let
|
|||
description = "A script for loading secrets before launching the sync.";
|
||||
default = [];
|
||||
};
|
||||
|
||||
config = lib.mkOption {
|
||||
type = lib.types.attrs;
|
||||
description = "The rclone config to use for creating the mount.";
|
||||
visible = false;
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
environment = syncProviders.${config.type}.envLoader config;
|
||||
secretsScript = syncProviders.${config.type}.secretLoader config;
|
||||
config = syncProviders.${config.type}.configLoader config;
|
||||
};
|
||||
});
|
||||
in {
|
||||
|
|
Loading…
Reference in a new issue