Allow configuring vfs
This commit is contained in:
parent
b2edfe64b9
commit
b285320436
1 changed files with 64 additions and 2 deletions
|
@ -89,6 +89,44 @@ let
|
|||
default = "";
|
||||
};
|
||||
|
||||
vfs = {
|
||||
enable = lib.mkEnableOption "Virtual File System";
|
||||
|
||||
mode = lib.mkOption {
|
||||
type = lib.types.nullOr (lib.types.enum [
|
||||
"minimal"
|
||||
"writes"
|
||||
"full"
|
||||
]);
|
||||
description = "The cache mode to use.";
|
||||
default = "full";
|
||||
};
|
||||
|
||||
dirCacheTime = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
description = "The time to cache directory entries for.";
|
||||
default = null;
|
||||
};
|
||||
|
||||
pollInterval = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
description = "The time to wait between polling for changes.";
|
||||
default = null;
|
||||
};
|
||||
|
||||
bufferSize = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
description = "The maximum size of the buffer per size to allocate.";
|
||||
default = null;
|
||||
};
|
||||
|
||||
maxAge = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
description = "The maximum age of cached files to keep.";
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
|
||||
extraArgs = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
description = "A set of additional arguments to pass to `rclone mount`.";
|
||||
|
@ -115,7 +153,23 @@ let
|
|||
(name: path: "export ${name}=\"$(cat ${lib.escapeShellArg path})\"")
|
||||
config.secrets));
|
||||
|
||||
args = config.extraArgs;
|
||||
args = config.extraArgs ++ (
|
||||
let
|
||||
vfs = config.vfs;
|
||||
in (
|
||||
lib.optionals vfs.enable
|
||||
(builtins.attrValues (
|
||||
lib.attrsets.concatMapAttrs
|
||||
(name: value:
|
||||
lib.optionalAttrs
|
||||
(value != null)
|
||||
{ name = "--${name}=${lib.escapeShellArg value}"; })
|
||||
{
|
||||
vfs-cache-mode = vfs.mode;
|
||||
vfs-cache-poll-interval = vfs.pollInterval;
|
||||
vfs-cache-max-size = vfs.bufferSize;
|
||||
vfs-cache-max-age = vfs.maxAge;
|
||||
}))));
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -320,6 +374,12 @@ in {
|
|||
global = true;
|
||||
};
|
||||
|
||||
globalArgs = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
description = "The arguments to pass to `rclone mount` for each configuration.";
|
||||
default = [ ];
|
||||
};
|
||||
|
||||
configs = (builtins.mapAttrs
|
||||
(name: provider: lib.mkOption {
|
||||
type = lib.types.attrsOf (lib.types.submodule provider.module);
|
||||
|
@ -394,7 +454,9 @@ in {
|
|||
${sync.secretsScript}
|
||||
mkdir -p ${sync.path}
|
||||
mkdir -p /tmp/rclone
|
||||
${lib.getExe pkgs.rclone} mount --config ${configFile} ${name}: ${sync.path}
|
||||
${lib.getExe pkgs.rclone} mount ${
|
||||
builtins.concatStringsSep " " (cfg.globalArgs ++ sync.args)
|
||||
} --config ${configFile} ${name}: ${sync.path}
|
||||
'';
|
||||
in
|
||||
(lib.getExe script);
|
||||
|
|
Loading…
Reference in a new issue