Add rclone
This commit is contained in:
parent
cb3645ff21
commit
aada678370
2 changed files with 116 additions and 23 deletions
75
home-manager/modules/rclone/default.nix
Normal file
75
home-manager/modules/rclone/default.nix
Normal file
|
@ -0,0 +1,75 @@
|
|||
{ pkgs, config, lib, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.eboskma.programs.rclone;
|
||||
|
||||
rcloneConnectionString = mount:
|
||||
let
|
||||
type = mount.remoteConfig.type;
|
||||
config = builtins.removeAttrs mount.remoteConfig [ "type" ];
|
||||
connectionStringOptions = mapAttrsToList (key: value: "${key}=${builtins.toJSON value}") config;
|
||||
in
|
||||
":${type},${builtins.concatStringsSep "," connectionStringOptions}:${mount.remote}";
|
||||
|
||||
rcloneRemote = with types; attrsOf (oneOf [ str int bool ]);
|
||||
|
||||
rcloneMount = with types; submodule {
|
||||
options = {
|
||||
remoteConfig = mkOption {
|
||||
description = "Configuration for the remote to use";
|
||||
type = rcloneRemote;
|
||||
};
|
||||
remote = mkOption {
|
||||
description = "Remote path";
|
||||
type = str;
|
||||
};
|
||||
local = mkOption {
|
||||
description = "Local mountpoint";
|
||||
type = path;
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
options.eboskma.programs.rclone = {
|
||||
enable = mkEnableOption "rclone";
|
||||
|
||||
mounts = mkOption {
|
||||
description = "Mount remotes on a local path";
|
||||
type = with types; listOf rcloneMount;
|
||||
default = [ ];
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf (cfg.enable) {
|
||||
home.packages = [ pkgs.rclone ];
|
||||
|
||||
systemd.user.services = builtins.listToAttrs (builtins.map
|
||||
(mount:
|
||||
let
|
||||
localPath = toString mount.local;
|
||||
unitName = builtins.replaceStrings [ "/" ] [ "-" ] (builtins.substring 1 (builtins.stringLength localPath) localPath);
|
||||
in
|
||||
{
|
||||
name = "rclone-${unitName}";
|
||||
value = {
|
||||
Unit = {
|
||||
Description = "rclone mount ${unitName}";
|
||||
After = [ "network.target" ];
|
||||
};
|
||||
|
||||
Service = {
|
||||
ExecStart = "${pkgs.rclone}/bin/rclone mount --vfs-cache-mode full --vfs-cache-poll-interval 5s --poll-interval 5s --dir-cache-time 10s ${rcloneConnectionString mount} ${mount.local}";
|
||||
ExecStop = "${pkgs.fuse}/bin/fusermount -zu ${mount.local}";
|
||||
Restart = "on-failure";
|
||||
RestartSec = 10;
|
||||
};
|
||||
|
||||
Install = {
|
||||
WantedBy = [ "default.target" ];
|
||||
};
|
||||
};
|
||||
})
|
||||
cfg.mounts);
|
||||
};
|
||||
}
|
|
@ -76,6 +76,23 @@ in
|
|||
gpg.enable = true;
|
||||
neovim.enable = true;
|
||||
obs-studio.enable = true;
|
||||
rclone = {
|
||||
enable = true;
|
||||
mounts = [
|
||||
{
|
||||
remote = "org-roam";
|
||||
local = "/home/erwin/org-roam";
|
||||
remoteConfig = {
|
||||
type = "sftp";
|
||||
host = "zh2088.rsync.net";
|
||||
user = "zh2088";
|
||||
key_file = "~/.ssh/id_ed25519-rsync.net";
|
||||
md5sum_command = "md5 -r";
|
||||
sha2sum_command = "sha1 -r";
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
rofi.enable = true;
|
||||
vscode.enable = true;
|
||||
solvespace.enable = true;
|
||||
|
@ -127,6 +144,7 @@ in
|
|||
quintom-cursor-theme
|
||||
procs
|
||||
ripgrep
|
||||
signal-desktop
|
||||
solo2-cli
|
||||
steam
|
||||
steamcmd
|
||||
|
@ -209,29 +227,29 @@ in
|
|||
inputs.emacs-overlay.overlay
|
||||
];
|
||||
}
|
||||
../../home-manager/modules/alacritty
|
||||
../../home-manager/modules/bat
|
||||
../../home-manager/modules/dropbox
|
||||
../../home-manager/modules/dunst
|
||||
../../home-manager/modules/emacs
|
||||
../../home-manager/modules/electron
|
||||
../../home-manager/modules/firefox
|
||||
../../home-manager/modules/fish
|
||||
../../home-manager/modules/foot
|
||||
../../home-manager/modules/git
|
||||
../../home-manager/modules/gpg
|
||||
../../home-manager/modules/neovim
|
||||
../../home-manager/modules/obs-studio
|
||||
../../home-manager/modules/rofi
|
||||
../../home-manager/modules/vscode
|
||||
../../home-manager/modules/solvespace
|
||||
../../home-manager/modules/ssh
|
||||
../../home-manager/modules/sway
|
||||
../../home-manager/modules/tea
|
||||
../../home-manager/modules/tmux
|
||||
../../home-manager/modules/waybar
|
||||
../../home-manager/modules/zathura
|
||||
];
|
||||
# ../../home-manager/modules/alacritty
|
||||
# ../../home-manager/modules/bat
|
||||
# ../../home-manager/modules/dropbox
|
||||
# ../../home-manager/modules/dunst
|
||||
# ../../home-manager/modules/emacs
|
||||
# ../../home-manager/modules/electron
|
||||
# ../../home-manager/modules/firefox
|
||||
# ../../home-manager/modules/fish
|
||||
# ../../home-manager/modules/foot
|
||||
# ../../home-manager/modules/git
|
||||
# ../../home-manager/modules/gpg
|
||||
# ../../home-manager/modules/neovim
|
||||
# ../../home-manager/modules/obs-studio
|
||||
# ../../home-manager/modules/rofi
|
||||
# ../../home-manager/modules/vscode
|
||||
# ../../home-manager/modules/solvespace
|
||||
# ../../home-manager/modules/ssh
|
||||
# ../../home-manager/modules/sway
|
||||
# ../../home-manager/modules/tea
|
||||
# ../../home-manager/modules/tmux
|
||||
# ../../home-manager/modules/waybar
|
||||
# ../../home-manager/modules/zathura let mut is_pk = false;
|
||||
] ++ (map (mod: (../../home-manager/modules + "/${mod}")) (builtins.attrNames (builtins.readDir ../../home-manager/modules)));
|
||||
};
|
||||
|
||||
programs = {
|
||||
|
|
Loading…
Reference in a new issue