diff options
| author | tv <tv@krebsco.de> | 2026-11-22 19:01:16 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-22 19:37:36 +0000 |
| commit | f446498e11f087c66fb9b0e53a707c493f46d217 (patch) | |
| tree | 7cea332aab51434fc9164a079e55b42ade79107d | |
| parent | 6142d5884ac8af0f779a4416b84099f11086721b (diff) | |
configs/claude: Remote Control's questions, answered by the unit
Remote Control asks two things: whether to enable it, once per machine
(remoteDialogSeen in ~/.claude.json, which claude remote-control checks
before it asks), and to trust ~/remotes/NAME, once per remote
(projects.DIR.hasTrustDialogAccepted). The unit answers both now,
before it starts: enabling it is what the units are for, and
~/remotes/NAME is the remote's own directory, just made. So, but for
claude auth login, no remote needs an attach. Atomically, and only
once there is a ~/.claude.json (after the login); if it fails, or a
remote writes back what it read before, Remote Control asks, as before.
| -rw-r--r-- | configs/claude.nix | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/configs/claude.nix b/configs/claude.nix index 345a70a..b7ebb75 100644 --- a/configs/claude.nix +++ b/configs/claude.nix @@ -11,10 +11,10 @@ # for Claude Code (sessions, memory, trust), on the repositories in ~/src, # which all remotes share. Each runs as claude in a tmux of its own, # which root opens with claude-remote attach [NAME]. Once, as root: -# runuser -l claude -c 'claude auth login', then, for each NAME, -# claude-remote attach NAME and answer Remote Control's questions there -# (enable it, trust ~/remotes/NAME). The state is in /home/claude, i.e. -# on the run script's --home drive, which is required. +# runuser -l claude -c 'claude auth login'. Remote Control's questions +# (enable it, once per machine; trust ~/remotes/NAME) the unit answers. +# The state is in /home/claude, i.e. on the run script's --home drive, +# which is required. { config, lib, pkgs, ... }: let # The tmux of claude-remote-control@NAME. @@ -161,6 +161,21 @@ in esac mkdir -p /home/claude/remotes/"$1" ''} %i" + # Remote Control's questions, answered, rather than asked in the + # terminal: enable it (remoteDialogSeen, once per machine; that's + # what the units are for), and trust ~/remotes/NAME, the remote's + # own directory, just made. In ~/.claude.json (once there is + # one, i.e. after the login), atomically; if a remote writes back + # what it read before, and an answer gets lost, Remote Control + # asks again, as before. + "${pkgs.writeShellScript "claude-remote-control-trust" '' + f=/home/claude/.claude.json d=/home/claude/remotes/$1 + test -f "$f" || exit 0 + if ! ${pkgs.jq}/bin/jq -e --arg d "$d" '.remoteDialogSeen == true and .projects[$d].hasTrustDialogAccepted == true' "$f" >/dev/null; then + ${pkgs.jq}/bin/jq --arg d "$d" '.remoteDialogSeen = true | .projects[$d].hasTrustDialogAccepted = true' "$f" > "$f.trust" && + mv "$f.trust" "$f" || rm -f "$f.trust" + fi + ''} %i" # As root (+), stateDir being root's. "+${remember} %i" ]; |
