Simplify creating login options

This commit is contained in:
Manuel Thalmann 2024-05-16 01:16:12 +02:00
parent 8da71a0b9e
commit b0d76f8f46

View file

@ -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;