So I use Emacs because it is a great tool and I am productive with it. I also code on a development box to avoid x86=>aarch64 compatibility issues with many things on the Mac. Lastly I use NixOS and the Nix package manager on the dev server and Mac respectively.
So I hit a problem. I hadn't noticed it until I was screen sharing and needed to grab some text from the file I was looking at and paste it into chat. I couldn't. The problem with running on a remote box via the terminal is the clipboard exists on the remote server and not locally.
I found a solution using something that has been around forever, X11. The workflow is a bit tedious, but definitely scriptable at some point.
First I needed to update my NixOS server to allow X11 forwarding.
{ config, pkgs, ... }:
let
[...]
in {
[...]
services.xserver.enable = true;
services.openssh.enable = true;
services.openssh.forwardX11 = true;
programs.ssh.forwardX11 = true;
programs.ssh.setXAuthLocation = true;
[...]
}
Now that I had this enabled I needed XQartz on the Mac. I attempted this install with Nix but it borked pretty bad so I just downloaded it from the site.
After this I open my terminal and log in to the remote box.
ssh -X user@devbox
emacsclient -nw [path/to/work]
When I copy text in emacs in the terminal it forwards the clipboard to XQuartz and thus the mac.