-{ pkgs, lib, config, hostName, ... }:
+{ pkgs, ... }:
with builtins;
{
-home-manager.users.sevy = {
- systemd.user.services."rsync-term@" = {
- Unit = {
- Description = "rsync terminal for: %I";
- After = [ "graphical-session.target" ];
- StopWhenUnneeded = false;
+ home-manager.users.sevy = {
+ systemd.user.services."rsync-term@" = {
+ Unit = {
+ Description = "rsync terminal for: %I";
+ After = [ "graphical-session.target" ];
+ StopWhenUnneeded = false;
+ };
+ Service = {
+ Type = "simple";
+ ExecStart = pkgs.writeShellScript "rsync-term" ''
+ FS_LABEL=$1
+ set -eux
+ ${pkgs.xterm}/bin/xterm -fg white -bg black -fa Monospace -fs 6 \
+ -title "rsync backup to: $FS_LABEL" -e "journalctl --user -f -o short \
+ -u rsync-backup@$FS_LABEL"
+ '' + " %I";
+ };
};
- Service = {
- Type = "simple";
- ExecStart = pkgs.writeShellScript "rsync-term" ''
- FS_LABEL=$1
- set -eux
- ${pkgs.xterm}/bin/xterm -fg white -bg black -fa Monospace -fs 6 \
- -title "rsync backup to: $FS_LABEL" -e "journalctl --user -f -o short \
- -u rsync-backup@$FS_LABEL"
- '' + " %I";
+ systemd.user.services."rsync-backup@" = {
+ Unit = {
+ Description = "rsync backup: %i";
+ Wants = [ "rsync-term@%i.service" ];
+ BindsTo = [ "sys-subsystem-usb-%i.device" ];
+ };
+ Service = {
+ Type = "oneshot";
+ SyslogIdentifier = "rsync-backup@%i";
+ ExecStart = pkgs.writeShellScript "rsync-backup" ''
+ FS_LABEL=$1
+ set -eux
+ DEVICE=$(${pkgs.util-linux}/bin/blkid -l -o device -t LABEL="$FS_LABEL")
+ while ! ${pkgs.glib}/bin/gio mount --device "$DEVICE"
+ do test ! -d /run/media/sevy/"$FS_LABEL" || break
+ sleep 1
+ done
+ ${pkgs.rsync}/bin/rsync --verbose --itemize-changes \
+ --partial --recursive --times \
+ --compress-level=0 --delete --delete-before \
+ /run/media/sevy/"$FS_LABEL" \
+ ~sevy/Documents/
+ systemctl --user --no-block stop rsync-term@"$FS_LABEL"
+ '' + " %I";
+ };
};
};
- systemd.user.services."rsync-backup@" = {
- Unit = {
- Description = "rsync backup: %i";
- Wants = [ "rsync-term@%i.service" ];
- BindsTo = [ "sys-subsystem-usb-%i.device" ];
- };
- Service = {
- Type = "oneshot";
- SyslogIdentifier = "rsync-backup@%i";
- ExecStart = pkgs.writeShellScript "rsync-backup" ''
- FS_LABEL=$1
- set -eux
- DEVICE=$(${pkgs.util-linux}/bin/blkid -l -o device -t LABEL="$FS_LABEL")
- while ! ${pkgs.glib}/bin/gio mount --device "$DEVICE"
- do test ! -d /run/media/sevy/"$FS_LABEL" || break
- sleep 1
- done
- ${pkgs.rsync}/bin/rsync --verbose --itemize-changes \
- --partial --recursive --times \
- --compress-level=0 --delete --delete-before \
- /run/media/sevy/"$FS_LABEL" \
- ~sevy/Documents/
- systemctl --user --no-block stop rsync-term@"$FS_LABEL"
- '' + " %I";
- };
- };
-};
}