1 { pkgs, lib, config, hostName, ... }:
4 home-manager.users.sevy = {
5 systemd.user.services."rsync-term@" = {
7 Description = "rsync terminal for: %I";
8 After = [ "graphical-session.target" ];
9 StopWhenUnneeded = false;
13 ExecStart = pkgs.writeShellScript "rsync-term" ''
16 ${pkgs.xterm}/bin/xterm -fg white -bg black -fa Monospace -fs 6 \
17 -title "rsync backup to: $FS_LABEL" -e "journalctl --user -f -o short \
18 -u rsync-backup@$FS_LABEL"
22 WantedBy = [ "graphical-session.target" ];
25 systemd.user.services."rsync-backup@" = {
27 Description = "rsync backup: %i";
28 Wants = [ "rsync-term@%i.service" ];
29 BindsTo = [ "sys-subsystem-usb-%i.device" ];
33 SyslogIdentifier = "rsync-backup@%i";
34 ExecStart = pkgs.writeShellScript "rsync-backup" ''
37 DEVICE=$(${pkgs.util-linux}/bin/blkid -l -o device -t LABEL="$FS_LABEL")
38 ${pkgs.glib}/bin/gio mount --device "$DEVICE"
39 ${pkgs.rsync}/bin/rsync --verbose --itemize-changes \
40 --partial --recursive --times \
41 --compress-level=0 --delete --delete-before \
42 /run/media/sevy/"$FS_LABEL" \
44 systemctl --user --no-block stop rsync-term@"$FS_LABEL"