2022-03-29 11:01:27 +02:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
2021-11-30 15:38:52 +01:00
|
|
|
let
|
|
|
|
|
mountdir = "/mnt/genc";
|
2022-02-15 12:46:41 +01:00
|
|
|
mountdir2 = "/mnt/gdrive";
|
2023-01-29 17:45:45 +01:00
|
|
|
cachedir = "/mnt/cache/rclone";
|
2021-11-30 15:38:52 +01:00
|
|
|
user = "mc-fucker";
|
|
|
|
|
group = "users";
|
2022-03-29 11:01:27 +02:00
|
|
|
cfg = config.services.rclone;
|
2021-11-30 15:38:52 +01:00
|
|
|
in
|
|
|
|
|
{
|
2022-03-29 11:01:27 +02:00
|
|
|
|
|
|
|
|
# options.services.rclone = {
|
|
|
|
|
# cacheSize = lib.mkOption {
|
|
|
|
|
# type = lib.types.str;
|
|
|
|
|
# default = "20G";
|
|
|
|
|
# description = "The maximum size of the vfs cache";
|
|
|
|
|
# };
|
|
|
|
|
# };
|
|
|
|
|
|
|
|
|
|
imports = [ ./rclone-options.nix ];
|
|
|
|
|
|
2021-11-30 15:38:52 +01:00
|
|
|
programs.fuse.userAllowOther = true;
|
|
|
|
|
systemd.services.genc_mount = {
|
|
|
|
|
description = "mount encrypted gdrive";
|
|
|
|
|
after = [ "network-online.target" ];
|
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
#path = with pkgs; [ fuse rclone ];
|
|
|
|
|
#path = with pkgs; [ "/run/wrappers/" ];
|
|
|
|
|
path = [ "/run/wrappers/" ];
|
|
|
|
|
preStart = ''
|
|
|
|
|
[ ! -d ${mountdir} ] && mkdir -p ${mountdir} && chown ${user} ${mountdir}
|
|
|
|
|
[ ! -d ${cachedir} ] && mkdir -p ${cachedir} && chown ${user} ${cachedir}
|
|
|
|
|
ls /home/mc-fucker
|
|
|
|
|
'';
|
|
|
|
|
postStop = "fusermount -uz ${mountdir}";
|
|
|
|
|
#postStart = "
|
|
|
|
|
serviceConfig = {
|
|
|
|
|
ExecStart = ''
|
|
|
|
|
${pkgs.rclone}/bin/rclone mount genc: ${mountdir} \
|
|
|
|
|
--config /home/mc-fucker/.config/rclone/rclone.conf \
|
|
|
|
|
--allow-other \
|
|
|
|
|
--dir-cache-time 5000h \
|
|
|
|
|
--attr-timeout 5000h \
|
|
|
|
|
--log-level INFO \
|
|
|
|
|
--poll-interval 30s \
|
|
|
|
|
--umask 002 \
|
|
|
|
|
--cache-dir=${cachedir} \
|
|
|
|
|
--drive-pacer-min-sleep 10ms \
|
|
|
|
|
--drive-pacer-burst 1000 \
|
|
|
|
|
--vfs-cache-mode full \
|
2022-03-29 11:01:27 +02:00
|
|
|
--vfs-cache-max-size ${cfg.cacheSize} \
|
2021-11-30 15:38:52 +01:00
|
|
|
--vfs-cache-max-age 5000h \
|
|
|
|
|
--vfs-cache-poll-interval 5m
|
|
|
|
|
'';
|
|
|
|
|
#Type = "notify";
|
|
|
|
|
Type = "simple";
|
|
|
|
|
Restart = "on-failure";
|
|
|
|
|
RestartSec = "5s";
|
|
|
|
|
User = user;
|
|
|
|
|
#Group = group;
|
|
|
|
|
};
|
|
|
|
|
};
|
2022-02-15 12:46:41 +01:00
|
|
|
|
|
|
|
|
systemd.services.gdrive_mount = {
|
|
|
|
|
description = "mount gdrive";
|
|
|
|
|
after = [ "network-online.target" ];
|
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
#path = with pkgs; [ fuse rclone ];
|
|
|
|
|
#path = with pkgs; [ "/run/wrappers/" ];
|
|
|
|
|
path = [ "/run/wrappers/" ];
|
|
|
|
|
preStart = ''
|
|
|
|
|
[ ! -d ${mountdir2} ] && mkdir -p ${mountdir2} && chown ${user} ${mountdir2}
|
|
|
|
|
[ ! -d ${cachedir} ] && mkdir -p ${cachedir} && chown ${user} ${cachedir}
|
|
|
|
|
ls /home/mc-fucker
|
|
|
|
|
'';
|
|
|
|
|
postStop = "fusermount -uz ${mountdir2}";
|
|
|
|
|
#postStart = "
|
|
|
|
|
serviceConfig = {
|
|
|
|
|
ExecStart = ''
|
2022-08-08 20:43:02 +02:00
|
|
|
${pkgs.rclone}/bin/rclone mount gdrive:/shared ${mountdir2} \
|
2022-02-15 12:46:41 +01:00
|
|
|
--config /home/mc-fucker/.config/rclone/rclone.conf \
|
|
|
|
|
--allow-other \
|
|
|
|
|
--dir-cache-time 5000h \
|
|
|
|
|
--attr-timeout 5000h \
|
|
|
|
|
--log-level INFO \
|
|
|
|
|
--poll-interval 30s \
|
|
|
|
|
--umask 002 \
|
|
|
|
|
--cache-dir=${cachedir} \
|
|
|
|
|
--drive-pacer-min-sleep 10ms \
|
|
|
|
|
--drive-pacer-burst 1000 \
|
|
|
|
|
--vfs-cache-mode full \
|
2022-03-29 11:01:27 +02:00
|
|
|
--vfs-cache-max-size ${cfg.cacheSize} \
|
2022-02-15 12:46:41 +01:00
|
|
|
--vfs-cache-max-age 5000h \
|
|
|
|
|
--vfs-cache-poll-interval 5m
|
|
|
|
|
'';
|
|
|
|
|
#Type = "notify";
|
|
|
|
|
Type = "simple";
|
|
|
|
|
Restart = "on-failure";
|
|
|
|
|
RestartSec = "5s";
|
|
|
|
|
User = user;
|
|
|
|
|
#Group = group;
|
|
|
|
|
};
|
|
|
|
|
};
|
2021-11-30 15:38:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# vim: set et ts=2 sw=2 ai:
|