summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-22 18:21:51 +0000
committertv <tv@krebsco.de>2026-11-22 19:37:36 +0000
commit6142d5884ac8af0f779a4416b84099f11086721b (patch)
tree9a8f0d9e3f5a6c48087935f0fded9a92fccdc490
parentce6d7ed1cfb45f286305913113839f5a0f3be197 (diff)
configs/claude: a static remote taken out goes on, as a dynamic one
The restore service keeps the static remotes of each boot (in /home/.var/lib/claude/static-remotes); one that was static at the last boot, but isn't anymore, gets a state file, i.e. becomes dynamic, and starts again, as long as it has a directory. To retire one: claude-remote stop NAME, as for any dynamic one. The first boot with this only notes the static ones.
-rw-r--r--configs/claude.nix19
-rw-r--r--pkgs/claude-remote.nix3
2 files changed, 19 insertions, 3 deletions
diff --git a/configs/claude.nix b/configs/claude.nix
index 205078b..345a70a 100644
--- a/configs/claude.nix
+++ b/configs/claude.nix
@@ -5,7 +5,8 @@
# systemd.targets.multi-user.wants = [ "claude-remote-control@NAME.service" ];
# 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).
+# claude-remote stop NAME (see stateDir). One taken out of the layers
+# goes on like that, too, after the reboot (see staticFile).
# 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,
@@ -46,6 +47,9 @@ let
# what would be in /var/lib (which is on the tmpfs), on the home drive:
# root's, and readable for anyone.
stateDir = "/home/.var/lib/claude/remote-control";
+ # The remotes that were static at the last boot, so that the restore
+ # service makes the ones that aren't anymore dynamic, and they go on.
+ staticFile = "/home/.var/lib/claude/static-remotes";
static = map (u: lib.removeSuffix ".service" (lib.removePrefix "claude-remote-control@" u))
(lib.filter (lib.hasPrefix "claude-remote-control@") config.systemd.targets.multi-user.wants);
systemctl = "${config.systemd.package}/bin/systemctl";
@@ -168,7 +172,10 @@ in
};
# Starts the remotes in stateDir again, after a reboot, but for those
- # that are static now, which it forgets instead.
+ # that are static now, which it forgets instead; and before that, makes
+ # the ones that were static at the last boot, but aren't anymore (taken
+ # out of the configuration), dynamic, so they go on running, as long as
+ # they have a directory (to retire one: claude-remote stop NAME).
systemd.services.claude-remote-control-restore = {
wantedBy = [ "multi-user.target" ];
after = [ "systemd-tmpfiles-setup.service" ];
@@ -176,6 +183,14 @@ in
unitConfig.AssertPathIsMountPoint = "/home";
serviceConfig.Type = "oneshot";
script = ''
+ if test -f ${staticFile}; then
+ for name in $(cat ${staticFile}); do
+ if ! ${isStatic "$name"} && test -d /home/claude/remotes/"$name"; then
+ touch ${stateDir}/"$name"
+ fi
+ done
+ fi
+ printf '%s\n' ${lib.escapeShellArgs static} > ${staticFile}
for f in ${stateDir}/*; do
test -f "$f" || continue
name=''${f##*/}
diff --git a/pkgs/claude-remote.nix b/pkgs/claude-remote.nix
index ff49102..c692be1 100644
--- a/pkgs/claude-remote.nix
+++ b/pkgs/claude-remote.nix
@@ -71,7 +71,8 @@ let
Kinds:
static started by the system's configuration
- dynamic started here: lasts, across reboots, until stopped here
+ dynamic started here, or static until taken out of the
+ configuration: lasts, across reboots, until stopped here
- neither: stopped, or not started yet
EOF
}