Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions .agents/skills/clipboard/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ hex line each in `.gclpr/trusted` in `users/dev/home.darwin.nix`; `#` lines are
Adding or replacing a host key therefore also needs a `home-switch` on the Mac (user config, no root),
and on the NixOS host a `nixos-rebuild switch` (refreshes `/run/secrets`) followed by a
home-manager switch (re-runs the activation that copies it into `~/.gclpr/key`).
Because `gclpr server` reads `~/.gclpr/trusted` only at startup, `users/dev/home.darwin.nix`
hashes the trusted-keys content into `GCLPR_TRUSTED_SHA256` on the `gclpr-server` launchd
plist so `home-switch` automatically restarts `org.nix-community.home.gclpr-server`
whenever `.gclpr/trusted` changes (after `linkGeneration` updates the symlink).

## Testing

Expand Down Expand Up @@ -123,10 +127,13 @@ printf '\033]52;c;%s\007' "$(printf 'test-raw' | base64 | tr -d '\n')"
2. Verify the port is listening on the remote host: `netstat -tulpn | grep 2850`
3. Verify the macOS server is running: `launchctl list | grep gclpr` or `lsof -i :2850` on macOS.

**"authentication failed" or "bad signature":**
**"authentication failed", "bad signature", or `*** ERROR: unexpected EOF`:**
1. Verify the private key exists on the remote host: `ls -la ~/.gclpr/key` (should be 64 bytes, mode 400)
2. Verify the public key matches: compare `xxd ~/.gclpr/key.pub` on remote with the hex in `~/.gclpr/trusted` on macOS
3. Re-deploy keys: `nix run home-manager -- switch --flake .#dev` on remote
2. Verify the public key matches: compare `od -An -tx1 ~/.gclpr/key.pub | tr -d ' \n'` on remote with the hex in `~/.gclpr/trusted` on macOS
3. Verify `gclpr server` on macOS started *after* `~/.gclpr/trusted` was updated (`gclpr server` only reads `~/.gclpr/trusted` at startup, and rejects unknown keys by closing the connection, which surfaces on the client as `*** ERROR: unexpected EOF`):
`ps -o pid,lstart,command -p "$(pgrep -f 'gclpr server')"` vs `ls -la ~/.gclpr/trusted`.
If stale, restart it: `launchctl kickstart -k "gui/$(id -u)/org.nix-community.home.gclpr-server"`
4. Re-deploy keys: `nix run home-manager -- switch --flake .#dev` (or `.#cloudbox`) on remote, and `home-switch` on macOS

**Clipboard dies for a few minutes, then recovers on its own:**
Check `~/Library/Logs/cloudbox-dev-tunnel.err.log` (or `devbox-…`) on the Mac. Repeated
Expand Down
32 changes: 22 additions & 10 deletions users/dev/home.darwin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -214,22 +214,31 @@ let
if [ "$delay" -gt 60 ]; then delay=60; fi
done
'';

# gclpr clipboard bridge trusted keys (macOS server). One hex public key
# per line; gclpr skips blank lines and lines starting with '#'. Each
# NixOS host has its own keypair; the private half is gclpr_private_key
# in secrets/<host>.yaml.
#
# Bound here so `~/.gclpr/trusted` and `launchd.agents.gclpr-server` share
# one source: `gclpr server` reads trusted keys only at startup, so hashing
# this string into the plist makes home-manager's `setupLaunchAgents`
# bootout/bootstrap the agent when keys change (after `linkGeneration` has
# updated `~/.gclpr/trusted`) and leave it running on unrelated switches.
gclprTrusted = ''
# cloudbox (assets/gclpr/key.pub)
482806af5b5b4fefe00021b17761cfb1be4a4b8ccc240ce8ad3d2f981cc61f92
# devbox (assets/gclpr/devbox.pub)
131beaeed315f7d7c6a6e34f609af119be894c6c01274be525eccd9f5841c0e3
'';
in
lib.mkIf isDarwin {
home.file = {
# Darwin common.conf - empty (no special options needed locally)
".gnupg/common.conf".text = "";

# gclpr clipboard bridge trusted keys (macOS server). One hex public key
# per line; gclpr skips blank lines and lines starting with '#'. Each
# NixOS host has its own keypair; the private half is gclpr_private_key
# in secrets/<host>.yaml.
".gclpr/trusted".text = ''
# cloudbox (assets/gclpr/key.pub)
482806af5b5b4fefe00021b17761cfb1be4a4b8ccc240ce8ad3d2f981cc61f92
# devbox (assets/gclpr/devbox.pub)
131beaeed315f7d7c6a6e34f609af119be894c6c01274be525eccd9f5841c0e3
'';
# gclpr clipboard bridge trusted keys (macOS server) — see `gclprTrusted` above.
".gclpr/trusted".text = gclprTrusted;

};

Expand Down Expand Up @@ -1104,6 +1113,9 @@ lib.mkIf isDarwin {
HOME = config.home.homeDirectory;
LANG = "en_US.UTF-8";
LC_CTYPE = "en_US.UTF-8";
# gclpr reads ~/.gclpr/trusted only at startup; hashing it into the
# plist triggers setupLaunchAgents to bootout/bootstrap on key changes.
GCLPR_TRUSTED_SHA256 = builtins.hashString "sha256" gclprTrusted;
};
RunAtLoad = true;
KeepAlive = true;
Expand Down
Loading