From 6142d5884ac8af0f779a4416b84099f11086721b Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 22 Nov 2026 18:21:51 +0000 Subject: 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. --- configs/claude.nix | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'configs') 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##*/} -- cgit v1.3.1