
## Automatically mount our rsync.net backup site.
#
# vim: et:ts=2:sw=2:
#
{ pkgs, ... }:
{
  config = {
    systemd.services.fastmail-tmllc-mount = {
      description = "fastmail-tmllc mount";

      # Start once we're online.
      wantedBy = [ "default.target" ];
      wants = [ "network-online.target" ];
      after = [ "network-online.target" ];

      # Run using our local rclone config.
      environment = {
        HOME = "/home/deprekated";
      };

      # Ensure our mountpoint exists.
      preStart = ''
        ${pkgs.umount}/bin/umount /home/deprekated/tmllc-fastmail || true
        mkdir -p /home/deprekated/tmllc-fastmail
      '';

      # Run rclone mount.
      serviceConfig = {
        Type = "notify";

        ExecStart = "${pkgs.rclone}/bin/rclone mount --allow-other --uid 1000 --gid 100 --file-perms 600 --dir-perms 700 --vfs-cache-mode full tmllc:/ /home/deprekated/tmllc-fastmail";
        Restart = "on-failure";
      };
    };
  };
}
