Refactor config creation
This commit is contained in:
parent
8653798a3d
commit
8da71a0b9e
1 changed files with 9 additions and 10 deletions
|
@ -6,7 +6,7 @@ let
|
|||
owncloudVendor = "owncloud";
|
||||
owncloudName = "Owncloud";
|
||||
nextcloudVendor = "nextcloud";
|
||||
mkIfNotNull = value: result: lib.mkIf (value != null) result;
|
||||
mkIfNotNull = value: name: lib.mkIf (value != null) { ${name} = value; };
|
||||
|
||||
mkSystemdDependencyOption =
|
||||
{ default, global ? false, ... }: lib.mkOption {
|
||||
|
@ -140,17 +140,16 @@ let
|
|||
config = {
|
||||
config = lib.mkMerge [
|
||||
{ url = config.url; }
|
||||
(mkIfNotNull config.vendor { inherit (config) vendor; })
|
||||
(mkIfNotNull config.username { user = config.username; })
|
||||
(mkIfNotNull config.obscuredPassword { pass = config.obscuredPassword; })
|
||||
(mkIfNotNull config.bearerToken { bearer_token = config.bearerToken; })
|
||||
(mkIfNotNull config.vendor "vendor")
|
||||
(mkIfNotNull config.username "user")
|
||||
(mkIfNotNull config.obscuredPassword "pass")
|
||||
(mkIfNotNull config.bearerToken "bearer_token")
|
||||
];
|
||||
|
||||
secrets = (lib.optionalAttrs (config.obscuredPasswordFile != null) {
|
||||
RCLONE_WEBDAV_PASS = config.obscuredPasswordFile;
|
||||
}) // (lib.optionalAttrs (config.bearerTokenFile != null) {
|
||||
RCLONE_WEBDAV_BEARER_TOKEN = config.bearerTokenFile;
|
||||
});
|
||||
secrets = lib.mkMerge [
|
||||
(mkIfNotNull config.obscuredPasswordFile "RCLONE_WEBDAV_PASS")
|
||||
(mkIfNotNull config.bearerTokenFile "RCLONE_WEBDAV_BEARER_TOKEN")
|
||||
];
|
||||
};
|
||||
}));
|
||||
|
||||
|
|
Loading…
Reference in a new issue