From faf4a0a29090e143860a84fcb5855b8720c1c5a5 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Thu, 16 May 2024 00:32:49 +0200 Subject: [PATCH] Add extended options for Owncloud remotes --- lib/modules/rclone.nix | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/modules/rclone.nix b/lib/modules/rclone.nix index 05925e9..68c5213 100644 --- a/lib/modules/rclone.nix +++ b/lib/modules/rclone.nix @@ -129,11 +129,29 @@ let }; })); + mkOwncloudProvider = { displayName ? "Owncloud", vendor ? "owncloud" }: ( + { config, ... }: { + imports = [ + (mkWebdavProvider { inherit displayName vendor; }) + ]; + + options = { + baseUrl = lib.mkOption { + type = lib.types.str; + description = "The base url of the ${displayName} server for automatically determining the WebDAV url."; + }; + }; + + config = { + url = "${lib.strings.removeSuffix "/" (lib.strings.normalizePath config.baseUrl)}/remote.php/dav/files/${config.username}"; + }; + }); + syncProviders = { nextcloud = rec { displayName = "Nextcloud"; - module = mkWebdavProvider { + module = mkOwncloudProvider { inherit displayName; vendor = "nextcloud"; }; @@ -225,7 +243,7 @@ in { Install = { WantedBy = lib.optional sync.autoStart "${targetName}.target"; - After = builtins.concatLists(builtins.attrValues sync.systemdDependencies); + After = builtins.concatLists (builtins.attrValues sync.systemdDependencies); }; }; })