Make provider displayname more accessible

This commit is contained in:
Manuel Thalmann 2024-05-15 22:37:57 +02:00
parent 5e7d685d60
commit 52e6775be6

View file

@ -22,26 +22,8 @@ let
inherit default; inherit default;
}; };
mkProvider =
{
displayName ? "Custom",
secretsScript ? "",
environment ? { },
config ? { },
options ? { }
}:
{ ... }: {
inherit
displayName
secretsScript
environment
config
options
;
};
mkWebdavProvider = { vendor, vendorName }: ( mkWebdavProvider = { vendor, vendorName }: (
{ providerOptions, ... }@args: mkProvider { { providerOptions, ... }: {
displayName = vendorName; displayName = vendorName;
options = { options = {
@ -83,12 +65,16 @@ let
(mkIfNotNull providerOptions.username { user = providerOptions.username; }) (mkIfNotNull providerOptions.username { user = providerOptions.username; })
(mkIfNotNull providerOptions.obscuredPassword { pass = providerOptions.obscuredPassword; }) (mkIfNotNull providerOptions.obscuredPassword { pass = providerOptions.obscuredPassword; })
]; ];
} args); });
syncProviders = { syncProviders = {
nextcloud = mkProvider {}; nextcloud = rec {
proton = mkProvider {}; displayName = "Nextcloud";
manual = mkProvider {}; provider = (mkWebdavProvider {
vendor = "nextcloud";
vendorName = displayName;
});
};
}; };
mkSyncType = provider: lib.types.submodule ( mkSyncType = provider: lib.types.submodule (
@ -153,9 +139,9 @@ in {
}; };
configs = (builtins.mapAttrs configs = (builtins.mapAttrs
(name: provider: lib.mkOption { (name: providerDefinition: lib.mkOption {
type = lib.types.attrsOf (mkSyncType provider); type = lib.types.attrsOf (mkSyncType providerDefinition.provider);
description = "The ${(provider config).displayName} synchronizations to set up."; description = "The ${providerDefinition.displayName} synchronizations to set up.";
default = { }; default = { };
}) })
syncProviders); syncProviders);