Generate a config file for the use with rclone

This commit is contained in:
Manuel Thalmann 2024-05-15 21:10:35 +02:00
parent 824bcbfbe5
commit 5e7d685d60

View file

@ -2,6 +2,7 @@
let let
cfg = config.programs.rclone; cfg = config.programs.rclone;
targetName = "rclone"; targetName = "rclone";
mkIfNotNull = value: result: lib.mkIf (value != null) result;
mkSystemdDependencyOption = mkSystemdDependencyOption =
{ default, global ? false, ... }: lib.mkOption { { default, global ? false, ... }: lib.mkOption {
@ -40,7 +41,7 @@ let
}; };
mkWebdavProvider = { vendor, vendorName }: ( mkWebdavProvider = { vendor, vendorName }: (
mkProvider { { providerOptions, ... }@args: mkProvider {
displayName = vendorName; displayName = vendorName;
options = { options = {
@ -73,7 +74,16 @@ let
default = null; default = null;
}; };
}; };
});
config = lib.mkMerge [
{
inherit vendor;
url = providerOptions.url;
}
(mkIfNotNull providerOptions.username { user = providerOptions.username; })
(mkIfNotNull providerOptions.obscuredPassword { pass = providerOptions.obscuredPassword; })
];
} args);
syncProviders = { syncProviders = {
nextcloud = mkProvider {}; nextcloud = mkProvider {};
@ -205,6 +215,9 @@ in {
ExecStart = ExecStart =
let let
configFile = pkgs.writeText
"${serviceName}.conf"
(lib.generators.toINI { } { name = sync.config; });
script = pkgs.writeShellScriptBin serviceName '' script = pkgs.writeShellScriptBin serviceName ''
${sync.secretsScript} ${sync.secretsScript}
bash -c echo hello world bash -c echo hello world