Make sync providers distinguishable
This commit is contained in:
parent
b781eb7e08
commit
c4926df9f6
|
@ -17,6 +17,7 @@ let
|
|||
|
||||
mkProvider =
|
||||
{
|
||||
displayName ? "Custom",
|
||||
secretsScript ? "",
|
||||
environment ? { },
|
||||
config ? { },
|
||||
|
@ -25,6 +26,7 @@ let
|
|||
}:
|
||||
{ ... }: {
|
||||
inherit
|
||||
displayName
|
||||
secretsScript
|
||||
environment
|
||||
config
|
||||
|
@ -38,7 +40,7 @@ let
|
|||
manual = mkProvider {};
|
||||
};
|
||||
|
||||
syncType = lib.types.submodule (
|
||||
mkSyncType = provider: lib.types.submodule (
|
||||
{ config, name, ... }: {
|
||||
options = {
|
||||
type = lib.mkOption {
|
||||
|
@ -55,11 +57,8 @@ let
|
|||
|
||||
providerOptions = lib.mkOption {
|
||||
description = "The options of the sync";
|
||||
type = lib.types.oneOf [
|
||||
(builtins.map
|
||||
(provider: provider.options)
|
||||
syncProviders)
|
||||
];
|
||||
type = lib.types.submodule { inherit (provider config) options; };
|
||||
default = {};
|
||||
};
|
||||
|
||||
systemdDependencies = mkSystemdDependencyOption {
|
||||
|
@ -105,11 +104,12 @@ in {
|
|||
default = {};
|
||||
};
|
||||
|
||||
configs = lib.mkOption {
|
||||
type = lib.types.attrsOf syncType;
|
||||
description = "The synchronizations to set up.";
|
||||
default = {};
|
||||
};
|
||||
configs = (builtins.mapAttrs
|
||||
(name: provider: lib.mkOption {
|
||||
type = lib.types.attrsOf (mkSyncType provider);
|
||||
description = "The ${(provider config).displayName} synchronizations to set up.";
|
||||
})
|
||||
syncProviders);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -147,14 +147,16 @@ in {
|
|||
};
|
||||
};
|
||||
} // (
|
||||
lib.attrsets.concatMapAttrs
|
||||
(providerName: configs:
|
||||
lib.attrsets.concatMapAttrs
|
||||
(name: sync:
|
||||
let
|
||||
serviceName = "rclone-sync-${name}";
|
||||
serviceName = "rclone-${providerName}-sync-${name}";
|
||||
in {
|
||||
${serviceName} = {
|
||||
Unit = {
|
||||
Description = "${sync.type}";
|
||||
Description = "rclone sync service for ${name} at using ${providerName}";
|
||||
};
|
||||
|
||||
Service = {
|
||||
|
@ -178,6 +180,7 @@ in {
|
|||
};
|
||||
};
|
||||
})
|
||||
configs)
|
||||
cfg.configs);
|
||||
|
||||
targets.${targetName} = {
|
||||
|
|
Loading…
Reference in a new issue