diff --git a/lib/modules/rclone.nix b/lib/modules/rclone.nix index 9e2090f..cdb7d59 100644 --- a/lib/modules/rclone.nix +++ b/lib/modules/rclone.nix @@ -8,6 +8,28 @@ let nextcloudVendor = "nextcloud"; mkIfNotNull = value: name: lib.mkIf (value != null) { ${name} = value; }; + mkUsernameOption = { service }: lib.mkOption { + type = lib.types.nullOr lib.types.str; + description = "The user name for logging in to ${service}."; + default = null; + }; + + mkPasswordOption = { service }: lib.mkOption { + type = lib.types.nullOr lib.types.str; + description = "The password obscured using the `rclone obscure` command for logging in to ${service}."; + default = null; + }; + + mkPasswordFileOption = { service }: lib.mkOption { + type = lib.types.nullOr (lib.types.either lib.types.path lib.types.str); + description = "The path to a file containing the password obscured using the `rclone obscure` command for logging in to ${service}."; + default = null; + }; + + mkServerUsernameOption = { service }: mkUsernameOption { service = "the ${service} server."; }; + mkServerPasswordOption = { service }: mkPasswordOption { service = "the ${service} server."; }; + mkServerPasswordFileOption = { service }: mkPasswordFileOption { service = "the ${service} server."; }; + mkSystemdDependencyOption = { default, global ? false, ... }: lib.mkOption { type = lib.types.attrsOf (lib.types.listOf lib.types.str); @@ -106,23 +128,9 @@ let default = null; }; - username = lib.mkOption { - type = lib.types.nullOr lib.types.str; - description = "The user name for logging in to the ${displayName} server."; - default = null; - }; - - obscuredPassword = lib.mkOption { - type = lib.types.nullOr lib.types.str; - description = "The password obscured using the `rclone obscure` command for logging in to the ${displayName} server."; - default = null; - }; - - obscuredPasswordFile = lib.mkOption { - type = lib.types.nullOr (lib.types.either lib.types.path lib.types.str); - description = "The path to a file containing the password obscured using the `rclone obscure` command for logging in to the ${displayName} server."; - default = null; - }; + username = mkServerUsernameOption { service = displayName; }; + obscuredPassword = mkServerPasswordOption { service = displayName; }; + obscuredPasswordFile = mkServerPasswordFileOption { service = displayName; }; bearerToken = lib.mkOption { type = lib.types.nullOr lib.types.str;