fix and update rclone
This commit is contained in:
parent
b3b0c86d3e
commit
4b1245fea3
3 changed files with 60 additions and 8 deletions
|
|
@ -76,6 +76,7 @@
|
|||
./system/all.nix
|
||||
./system/browsers/firefox.nix
|
||||
./system/shell/fish.nix
|
||||
./system/tailscale/default.nix
|
||||
./system/hosts/${hostname}/default.nix
|
||||
./hardware/${hostname}.nix
|
||||
catppuccin.nixosModules.catppuccin
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{ pkgs, ... }:
|
||||
{ pkgs, lib, ... }:
|
||||
|
||||
{
|
||||
xdg.configFile."rclone/synology.conf".text = ''
|
||||
|
|
@ -7,22 +7,43 @@
|
|||
user = sckova
|
||||
host = nas.taila30609.ts.net
|
||||
key_file = ~/.ssh/key
|
||||
shell_type = unix
|
||||
root = home
|
||||
md5sum_command = "${pkgs.coreutils}/bin/md5sum";
|
||||
sha1sum_command = "${pkgs.coreutils}/bin/sha1sum";
|
||||
'';
|
||||
|
||||
systemd.user.services.synology-mount = {
|
||||
Unit = {
|
||||
Description = "Mount Synology NAS with Rclone and Home Manager.";
|
||||
After = [ "network-online.target" ];
|
||||
StartLimitIntervalSec = 30;
|
||||
StartLimitBurst = 3;
|
||||
After = [ "tailscaled.service" ];
|
||||
};
|
||||
|
||||
Service = {
|
||||
Type = "notify";
|
||||
ExecStartPre = "${pkgs.coreutils}/bin/mkdir -p %h/Synology";
|
||||
ExecStart = "${pkgs.rclone}/bin/rclone --config=%h/.config/rclone/synology.conf --vfs-cache-mode full --ignore-checksum mount \"synology:\" \"%h/Synology\"";
|
||||
ExecStop = "/run/wrappers/bin/fusermount -u %h/Synology/%i";
|
||||
Restart = "on-failure";
|
||||
ExecStartPre = ''
|
||||
if mountpoint -q %h/Synology; then
|
||||
/run/wrappers/bin/fusermount -uz %h/Synology
|
||||
fi
|
||||
${pkgs.coreutils}/bin/mkdir -p %h/Synology
|
||||
'';
|
||||
ExecStart = ''
|
||||
${pkgs.rclone}/bin/rclone \
|
||||
--config=%h/.config/rclone/synology.conf \
|
||||
--vfs-cache-mode full \
|
||||
--vfs-cache-max-size 10G \
|
||||
--vfs-cache-max-age 12h \
|
||||
--vfs-read-chunk-size 128M \
|
||||
--vfs-read-chunk-size-limit 2G \
|
||||
--buffer-size 64M \
|
||||
--dir-cache-time 72h \
|
||||
--ignore-checksum \
|
||||
--log-level INFO \
|
||||
mount "synology:" "%h/Synology"
|
||||
'';
|
||||
ExecStop = "/run/wrappers/bin/fusermount -uz %h/Synology/%i";
|
||||
StandardOutput = "journal";
|
||||
StandardError = "journal";
|
||||
};
|
||||
|
||||
Install = {
|
||||
|
|
|
|||
30
system/tailscale/default.nix
Normal file
30
system/tailscale/default.nix
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# https://github.com/tailscale/tailscale/issues/11504#issuecomment-2113331262
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
tailscaleWaitScript = pkgs.writeShellScript "tailscale-wait-for-ip" ''
|
||||
echo "Waiting for tailscale0 to get an IP address..."
|
||||
for i in {1..15}; do
|
||||
if ${lib.getExe' pkgs.iproute2 "ip"} addr show dev tailscale0 2>/dev/null | ${lib.getExe' pkgs.gnugrep "grep"} -q 'inet '; then
|
||||
echo "tailscale0 has IP address"
|
||||
exit 0
|
||||
fi
|
||||
echo "Attempt $i"
|
||||
sleep 1
|
||||
done
|
||||
echo "Warning: tailscale0 did not get IP address within 15 seconds"
|
||||
exit 0
|
||||
'';
|
||||
in
|
||||
{
|
||||
systemd.services.tailscaled = {
|
||||
serviceConfig = {
|
||||
ExecStartPost = tailscaleWaitScript;
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue