Rclone configuration

This commit is contained in:
Filippo Berto 2025-04-24 11:10:39 +02:00
parent 608808f8a2
commit 922e48d87e
Signed by: bertof
GPG key ID: 9DBF7E6A1D2CE9ED
30 changed files with 426 additions and 462 deletions

View 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/"; };
};
}

View 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/"; };
};
}

View file

@ -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 { });
};
}