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";
|
targetName = "rclone";
|
||||||
|
|
||||||
mkProvider =
|
mkProvider =
|
||||||
{ secretLoader ? ({ ... }: ""), envLoader ? ({ ... }: { }), options ? {}, ... }: {
|
{
|
||||||
|
secretLoader ? ({ ... }: ""),
|
||||||
|
envLoader ? ({ ... }: { }),
|
||||||
|
configLoader ? ({ ... }: { }),
|
||||||
|
options ? {},
|
||||||
|
...
|
||||||
|
}: {
|
||||||
inherit
|
inherit
|
||||||
secretLoader
|
secretLoader
|
||||||
envLoader
|
envLoader
|
||||||
|
configLoader
|
||||||
options
|
options
|
||||||
;
|
;
|
||||||
};
|
};
|
||||||
|
@ -24,8 +31,37 @@ let
|
||||||
inherit default;
|
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 = {
|
syncProviders = {
|
||||||
nextcloud = mkProvider {};
|
nextcloud = mkProvider {
|
||||||
|
options = lib.types.submodule (
|
||||||
|
(mkOwncloudOptions { }));
|
||||||
|
};
|
||||||
|
|
||||||
proton = mkProvider {};
|
proton = mkProvider {};
|
||||||
manual = mkProvider {};
|
manual = mkProvider {};
|
||||||
};
|
};
|
||||||
|
@ -45,6 +81,15 @@ let
|
||||||
default = true;
|
default = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
providerOptions = lib.mkOption {
|
||||||
|
description = "The options of the sync";
|
||||||
|
type = lib.types.oneOf [
|
||||||
|
(builtins.map
|
||||||
|
(provider: provider.options)
|
||||||
|
syncProviders)
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
systemdDependencies = mkSystemdDependencyOption {
|
systemdDependencies = mkSystemdDependencyOption {
|
||||||
default = cfg.systemdDependencies;
|
default = cfg.systemdDependencies;
|
||||||
};
|
};
|
||||||
|
@ -60,11 +105,18 @@ let
|
||||||
description = "A script for loading secrets before launching the sync.";
|
description = "A script for loading secrets before launching the sync.";
|
||||||
default = [];
|
default = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
config = lib.mkOption {
|
||||||
|
type = lib.types.attrs;
|
||||||
|
description = "The rclone config to use for creating the mount.";
|
||||||
|
visible = false;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
environment = syncProviders.${config.type}.envLoader config;
|
environment = syncProviders.${config.type}.envLoader config;
|
||||||
secretsScript = syncProviders.${config.type}.secretLoader config;
|
secretsScript = syncProviders.${config.type}.secretLoader config;
|
||||||
|
config = syncProviders.${config.type}.configLoader config;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
in {
|
in {
|
||||||
|
|
Loading…
Reference in a new issue