diff --git a/lib/modules/rclone.nix b/lib/modules/rclone.nix index 9c139f6..9e2090f 100644 --- a/lib/modules/rclone.nix +++ b/lib/modules/rclone.nix @@ -6,7 +6,7 @@ let owncloudVendor = "owncloud"; owncloudName = "Owncloud"; nextcloudVendor = "nextcloud"; - mkIfNotNull = value: result: lib.mkIf (value != null) result; + mkIfNotNull = value: name: lib.mkIf (value != null) { ${name} = value; }; mkSystemdDependencyOption = { default, global ? false, ... }: lib.mkOption { @@ -140,17 +140,16 @@ let config = { config = lib.mkMerge [ { url = config.url; } - (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; }) + (mkIfNotNull config.vendor "vendor") + (mkIfNotNull config.username "user") + (mkIfNotNull config.obscuredPassword "pass") + (mkIfNotNull config.bearerToken "bearer_token") ]; - secrets = (lib.optionalAttrs (config.obscuredPasswordFile != null) { - RCLONE_WEBDAV_PASS = config.obscuredPasswordFile; - }) // (lib.optionalAttrs (config.bearerTokenFile != null) { - RCLONE_WEBDAV_BEARER_TOKEN = config.bearerTokenFile; - }); + secrets = lib.mkMerge [ + (mkIfNotNull config.obscuredPasswordFile "RCLONE_WEBDAV_PASS") + (mkIfNotNull config.bearerTokenFile "RCLONE_WEBDAV_BEARER_TOKEN") + ]; }; }));