# pdtv26-brain: a Claude Code session with the box's channel, confined to its workspace, ~/pdtv26-brain. # People talk to it through the box. A systemd user unit; make install (brain/Makefile) puts it in place. # Attach: make attach, or @tmux@/bin/tmux -S /run/user/$UID/pdtv26-brain/tmux.sock attach (detach: C-b d) [Unit] Description=pdtv26-brain: Claude Code with the box's channel [Service] Type=forking WorkingDirectory=%h/pdtv26-brain Environment=PATH=%h/.local/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/usr/local/bin:/usr/bin:/bin Environment=TERM=xterm-256color # Its own config, login, and session state, inside its workspace: trust and approvals persist # (a bind-mounted ~/.claude.json can't be replaced by rename), and it never sees ~/.claude. Environment=CLAUDE_CONFIG_DIR=%h/pdtv26-brain/.config-claude RuntimeDirectory=pdtv26-brain # bwrap, not ProtectHome= and friends: with kernel.apparmor_restrict_unprivileged_userns=1 # the user manager cannot mount, and silently runs the service unconfined. # # The system is read-only, the Nix store and its own source (@src@) with it; the home directory # is empty (--tmpfs %h) but for what's bound back in: its workspace (writable; its config and cache # live there), its channel's keys (~/.config/pdtv26-brain: the channel runs inside the sandbox, as # Claude's child), and the claude binary. Whatever else lands in the home directory stays hidden. # Hiding %t removes the systemd and D-Bus sockets (systemd-run would escape), the ssh and gpg agents, # and tmux itself; hiding /tmp removes X. ExecStart=@tmux@/bin/tmux -S %t/pdtv26-brain/tmux.sock new-session -d -s pdtv26-brain \ @bubblewrap@/bin/bwrap --die-with-parent \ --ro-bind / / --dev /dev --proc /proc --tmpfs /tmp --tmpfs %t \ --tmpfs %h \ --bind %h/pdtv26-brain %h/pdtv26-brain \ --bind %h/pdtv26-brain/.cache %h/.cache \ --ro-bind %h/.config/pdtv26-brain %h/.config/pdtv26-brain \ --ro-bind %h/.local/bin/claude %h/.local/bin/claude \ --ro-bind %h/.local/share/claude %h/.local/share/claude \ claude -n pdtv26-brain --permission-mode auto --dangerously-load-development-channels server:box ExecStop=-@tmux@/bin/tmux -S %t/pdtv26-brain/tmux.sock kill-server # tmux exits 0 when claude exits, so on-failure would never fire. Restart=always RestartSec=30 [Install] WantedBy=default.target