Rclone configuration
This commit is contained in:
parent
608808f8a2
commit
922e48d87e
30 changed files with 426 additions and 462 deletions
8
modules/hm/rclone-mount-bertof.nix
Normal file
8
modules/hm/rclone-mount-bertof.nix
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{ config, nixosConfig, ... }: {
|
||||
imports = [ ./rclone-mount.nix ];
|
||||
rclone-mount = {
|
||||
enable = true;
|
||||
configPath = nixosConfig.age.secrets."minio_${config.home.username}".path;
|
||||
mounts = { "minio" = "/home/${config.home.username}/minio/"; };
|
||||
};
|
||||
}
|
||||
8
modules/hm/rclone-mount-tiziano.nix
Normal file
8
modules/hm/rclone-mount-tiziano.nix
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{ config, nixosConfig, ... }: {
|
||||
imports = [ ./rclone-mount.nix ];
|
||||
rclone-mount = {
|
||||
enable = true;
|
||||
configPath = nixosConfig.age.secrets."minio_${config.home.username}".path;
|
||||
mounts = { "minio" = "/home/${config.home.username}/minio/"; };
|
||||
};
|
||||
}
|
||||
|
|
@ -1,28 +1,43 @@
|
|||
{ pkgs, lib, config, nixosConfig, ... }:
|
||||
let
|
||||
|
||||
rclone_config = nixosConfig.age.secrets."s3_${nixosConfig.networking.hostName}".path;
|
||||
mounts = { "minio" = "/home/${config.home.username}/minio/"; };
|
||||
in
|
||||
{
|
||||
systemd.user.services = lib.attrsets.mapAttrs'
|
||||
(name: path: {
|
||||
name = "rclone-${name}";
|
||||
value = {
|
||||
Unit = {
|
||||
Description = "rclone mount for ${name}";
|
||||
After = [ "default.target" ];
|
||||
PartOf = [ "default.target" ];
|
||||
};
|
||||
Install.WantedBy = [ "default.target" ];
|
||||
Service = {
|
||||
Type = "simple";
|
||||
ExecStartPre = "${pkgs.coreutils}/bin/mkdir -p ${path}";
|
||||
ExecStart = "${pkgs.rclone}/bin/rclone --config ${rclone_config} mount ${name}:/ ${path} -v --vfs-cache-mode=writes --s3-upload-concurrency 32 --s3-chunk-size 128000";
|
||||
Restart = "on-failure";
|
||||
RestartSec = "30s";
|
||||
};
|
||||
{ pkgs, lib, config, ... }:
|
||||
let cfg = config.rclone-mount; in {
|
||||
options = {
|
||||
rclone-mount = {
|
||||
enable = lib.mkEnableOption "rclone mount user services";
|
||||
mounts = lib.mkOption {
|
||||
type = lib.types.attrs;
|
||||
default = { };
|
||||
example = { "minio" = "/home/${config.home.username}/minio/"; };
|
||||
description = "List of mount configurations";
|
||||
};
|
||||
})
|
||||
mounts;
|
||||
configPath = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "~/.config/rclone/rclone.conf";
|
||||
description = "Path to the rclone configuration";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
systemd.user.services = lib.attrsets.mapAttrs'
|
||||
(name: path: {
|
||||
name = "rclone-${name}";
|
||||
value = {
|
||||
Unit = {
|
||||
Description = "rclone mount for ${name}";
|
||||
After = [ "default.target" ];
|
||||
PartOf = [ "default.target" ];
|
||||
};
|
||||
Install.WantedBy = [ "default.target" ];
|
||||
Service = {
|
||||
Type = "simple";
|
||||
ExecStartPre = "${pkgs.coreutils}/bin/mkdir -p ${path}";
|
||||
ExecStart = "${pkgs.rclone}/bin/rclone --config '${cfg.configPath}' mount ${name}:/ ${path} -v --vfs-cache-mode=writes --s3-upload-concurrency 32 --s3-chunk-size 128000";
|
||||
Restart = "on-failure";
|
||||
RestartSec = "30s";
|
||||
};
|
||||
};
|
||||
})
|
||||
(if cfg.enable then cfg.mounts else { });
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue