diff options
Diffstat (limited to 'configs')
| -rw-r--r-- | configs/hermes.nix | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/configs/hermes.nix b/configs/hermes.nix index ab04b15..93dbfbf 100644 --- a/configs/hermes.nix +++ b/configs/hermes.nix @@ -138,19 +138,27 @@ in nixpkgs.config.allowUnfreePredicate = pkg: lib.getName pkg == "claude-code"; # hermes' home is stateDir, so this uses the service's state at ~/.hermes. - # tmux lets root attach to it. Quitting hermes ends the session, and - # systemd starts a new one. + # tmux lets root attach to it. Socket-activated: the first client + # starts the server, whose config starts hermes, and quitting hermes + # ends the session and the server (exit-empty), until the next client. + systemd.sockets.hermes-tmux = { + wantedBy = [ "sockets.target" ]; + socketConfig = { + ListenStream = "/run/hermes/tmux"; + SocketUser = "hermes"; + SocketMode = "0600"; + }; + }; systemd.services.hermes-tmux = { - wantedBy = [ "multi-user.target" ]; requires = [ "hermes-agent-setup.service" ]; after = [ "hermes-agent-setup.service" ]; - before = [ "serial-getty@ttyS0.service" ]; serviceConfig = { - Type = "forking"; User = "hermes"; - RuntimeDirectory = "hermes"; - ExecStart = "${tmux} new-session -d -s hermes ${lib.getExe config.services.hermes-agent.package} --tui"; - Restart = "always"; + # -D: in the foreground, on the socket from systemd. + ExecStart = "${pkgs.tmux}/bin/tmux -D -f ${pkgs.writeText "hermes-tmux.conf" '' + set -s exit-empty on + new-session -d -s hermes ${lib.getExe config.services.hermes-agent.package} --tui + ''}"; }; inherit (config.systemd.services.hermes-agent) path; }; @@ -186,6 +194,12 @@ in cp -r --no-preserve=mode ${claude-subscription-directsdk} "$p" chown -R hermes:hermes "$p" + # Hermes imports provider plugins from copies under runtime, one set + # per process, reclaimed by later processes when nothing holds them. + # Copies of a read-only plugin couldn't be removed, and a crash + # leaves its own; no Hermes runs yet, so none is in use. + rm -rf ${config.services.hermes-agent.stateDir}/.hermes/runtime/provider-plugins + # Writable for hermes, too, see HERMES_MANAGED below. chmod 0660 ${config.services.hermes-agent.stateDir}/.hermes/config.yaml ''; |
