summaryrefslogtreecommitdiffstats
path: root/configs/claude.nix
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-21 14:21:46 +0000
committertv <tv@krebsco.de>2026-11-21 14:21:46 +0000
commit0e9becdfccd96009464ea8acd36f88d27b8616f4 (patch)
treed981006dfce377cf377c64fd959648efac10516f /configs/claude.nix
parent0030f5807a9c583ed575cee537f27e6edc25f5cd (diff)
configs/claude: claude-remote, root's tool for the remotes
claude-remote list (the default) shows the remotes, static, dynamic, with a unit loaded, or with a directory, with their kind, state, and whether they trust their directory yet; inspect NAME shows a remote's unit, directory, trust, claude.ai session (bridge-pointer.json), and the last lines of its terminal; start, stop and restart NAME go through systemctl (a remote started here is dynamic: it lasts until stopped here), and start points to attach while the remote doesn't trust its directory; attach [NAME] opens its terminal (it's claude-attach, which is gone); log NAME shows its journal. Which remotes are static, it asks systemd (multi-user.target's wants), so changing them doesn't change it. A package (pkgs/claude-remote.nix), with bash completion of the commands and the remotes' names.
Diffstat (limited to 'configs/claude.nix')
-rw-r--r--configs/claude.nix31
1 files changed, 13 insertions, 18 deletions
diff --git a/configs/claude.nix b/configs/claude.nix
index e4fde84..05583a9 100644
--- a/configs/claude.nix
+++ b/configs/claude.nix
@@ -3,31 +3,26 @@
# One per remote, claude-remote-control@NAME, main by default; more by
# adding them in a layer:
# systemd.targets.multi-user.wants = [ "claude-remote-control@NAME.service" ];
-# or with systemctl start claude-remote-control@NAME, which lasts, across
-# reboots, until systemctl stop (see stateDir).
+# or with claude-remote start NAME (root's tool for the remotes, see
+# pkgs/claude-remote.nix), which lasts, across reboots, until
+# claude-remote stop NAME (see stateDir).
# A remote is a context: it works in ~/remotes/NAME, which is its project
# 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-attach [NAME]. Once, as root: runuser -l
-# claude -c 'claude auth login', then, for each NAME, claude-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.
+# 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.
{ config, lib, pkgs, ... }:
let
# The tmux of claude-remote-control@NAME.
tmux = name: "${pkgs.tmux}/bin/tmux -S /run/claude/${name}/tmux";
- # Root's way into claude's tmuxes.
- claude-attach = pkgs.writeShellScriptBin "claude-attach" ''
- # usage: claude-attach [NAME] (default: main)
- name=''${1:-main}
- if ! test -S /run/claude/"$name"/tmux; then
- echo "claude-attach: no claude-remote-control@$name running" >&2
- exit 1
- fi
- exec ${tmux "\"$name\""} attach -t claude
- '';
+ # Root's tool for the remotes.
+ claude-remote = pkgs.callPackage ../pkgs/claude-remote.nix {
+ inherit stateDir;
+ };
# Remotes started with systemctl, rather than by multi-user.target's
# wants (static), come back after a reboot: each has a file of its name
@@ -176,5 +171,5 @@ in
done
'';
};
- environment.systemPackages = [ claude-attach ];
+ environment.systemPackages = [ claude-remote ];
}