From 2596010ac9f1989fec32502fe1fc4b98cd20e104 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Thu, 16 May 2024 00:44:56 +0200 Subject: [PATCH] Add support for bearer tokens --- lib/modules/rclone.nix | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/modules/rclone.nix b/lib/modules/rclone.nix index acc0595..9519bc7 100644 --- a/lib/modules/rclone.nix +++ b/lib/modules/rclone.nix @@ -122,6 +122,18 @@ let description = "The path to a file containing the password obscured using the `rclone obscure` command for logging in to the ${displayName} server."; default = null; }; + + bearerToken = lib.mkOption { + type = lib.types.nullOr lib.types.str; + description = "The bearer token for logging in to the ${displayName} server."; + default = null; + }; + + bearerTokenFile = lib.mkOption { + type = lib.types.nullOr (lib.types.either lib.types.path lib.types.str); + description = "The path to a file containing the bearer token for logging in to the ${displayName} server."; + default = null; + }; }; config = { @@ -130,11 +142,14 @@ let (mkIfNotNull config.vendor { inherit (config) vendor; }) (mkIfNotNull config.username { user = config.username; }) (mkIfNotNull config.obscuredPassword { pass = config.obscuredPassword; }) + (mkIfNotNull config.bearerToken { bearer_token = config.bearerToken; }) ]; - secrets = lib.optionalAttrs (config.obscuredPasswordFile != null) { + secrets = (lib.optionalAttrs (config.obscuredPasswordFile != null) { RCLONE_WEBDAV_PASS = config.obscuredPasswordFile; - }; + }) // (lib.optionalAttrs (config.bearerTokenFile != null) { + RCLONE_WEBDAV_BEARER_TOKEN = config.bearerTokenFile; + }); }; }));