nixos: add claude-remote-control always-on service

Always-on systemd user service running `claude --remote-control` in a
detached tmux session (dedicated socket) pinned to /srv/dotfiles, with a
claude-rc-attach alias. Enabled on railbird-sf. Ad-hoc per-directory
sessions remain handled by the tmclaude shell function.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-09 05:22:36 -07:00
parent 83ab75a12c
commit 59fc652eab
3 changed files with 66 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
{
pkgs,
config,
lib,
makeEnable,
...
}: let
# Working directory the always-on session is pinned to. Ad-hoc sessions in
# other directories are handled by the `tmclaude` shell function instead.
workingDirectory = "/srv/dotfiles";
# Dedicated tmux socket + session name so the service owns its own tmux
# server (independent of the interactive one). Attach locally with:
# tmux -L claude-rc attach -t claude-rc
socket = "claude-rc";
sessionName = "claude-rc";
# Name the session registers under for native Remote Control (phone/web).
remoteName = config.networking.hostName;
# claude shells out to these for its tools; give the service a clean PATH.
servicePath = lib.makeBinPath (with pkgs; [
claude-code
tmux
bashInteractive
coreutils
findutils
git
gnugrep
gnused
nix
nodejs
openssh
ripgrep
zsh
]);
in
makeEnable config "myModules.claudeRemoteControl" false {
home-manager.users.imalison = {
systemd.user.services.claude-remote-control = {
Unit = {
Description = "Claude Code remote-control session";
After = ["network.target"];
};
Service = {
# tmux new-session -d daemonizes the server and returns.
Type = "forking";
Environment = ["PATH=${servicePath}"];
ExecStart = lib.concatStringsSep " " [
"${pkgs.tmux}/bin/tmux -L ${socket} new-session -d"
"-s ${sessionName} -c ${workingDirectory}"
"${pkgs.claude-code}/bin/claude --remote-control ${remoteName} --dangerously-skip-permissions"
];
ExecStop = "${pkgs.tmux}/bin/tmux -L ${socket} kill-server";
Restart = "on-failure";
RestartSec = 5;
};
Install.WantedBy = ["default.target"];
};
# Convenience: attach to the always-on session from any directory.
home.shellAliases.claude-rc-attach = "tmux -L ${socket} attach -t ${sessionName}";
};
}

View File

@@ -12,6 +12,7 @@
./cache-server.nix
./cache.nix
./chrome-favicon-dbus.nix
./claude-remote-control.nix
./code.nix
./cua.nix
./desktop.nix

View File

@@ -63,6 +63,7 @@
myModules.base.enable = true;
myModules.desktop.enable = true;
myModules.code.enable = true;
myModules.claudeRemoteControl.enable = true;
myModules.syncthing.enable = true;
myModules.fonts.enable = true;
myModules.plasma.enable = true;