fix and update rclone

This commit is contained in:
Sean Kovacs 2025-11-13 22:28:35 -05:00
commit 4b1245fea3
Signed by: sckova
GPG key ID: 00F325187C68651A
3 changed files with 60 additions and 8 deletions

View file

@ -76,6 +76,7 @@
./system/all.nix ./system/all.nix
./system/browsers/firefox.nix ./system/browsers/firefox.nix
./system/shell/fish.nix ./system/shell/fish.nix
./system/tailscale/default.nix
./system/hosts/${hostname}/default.nix ./system/hosts/${hostname}/default.nix
./hardware/${hostname}.nix ./hardware/${hostname}.nix
catppuccin.nixosModules.catppuccin catppuccin.nixosModules.catppuccin

View file

@ -1,4 +1,4 @@
{ pkgs, ... }: { pkgs, lib, ... }:
{ {
xdg.configFile."rclone/synology.conf".text = '' xdg.configFile."rclone/synology.conf".text = ''
@ -7,22 +7,43 @@
user = sckova user = sckova
host = nas.taila30609.ts.net host = nas.taila30609.ts.net
key_file = ~/.ssh/key 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 = { systemd.user.services.synology-mount = {
Unit = { Unit = {
Description = "Mount Synology NAS with Rclone and Home Manager."; Description = "Mount Synology NAS with Rclone and Home Manager.";
After = [ "network-online.target" ]; After = [ "tailscaled.service" ];
StartLimitIntervalSec = 30;
StartLimitBurst = 3;
}; };
Service = { Service = {
Type = "notify"; Type = "notify";
ExecStartPre = "${pkgs.coreutils}/bin/mkdir -p %h/Synology"; ExecStartPre = ''
ExecStart = "${pkgs.rclone}/bin/rclone --config=%h/.config/rclone/synology.conf --vfs-cache-mode full --ignore-checksum mount \"synology:\" \"%h/Synology\""; if mountpoint -q %h/Synology; then
ExecStop = "/run/wrappers/bin/fusermount -u %h/Synology/%i"; /run/wrappers/bin/fusermount -uz %h/Synology
Restart = "on-failure"; 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 = { Install = {

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