summaryrefslogtreecommitdiffstats
path: root/configs/hermes.nix
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-20 01:50:44 +0000
committertv <tv@krebsco.de>2026-11-20 02:58:19 +0100
commita211d2bd5946b7cc2db01e2f786cce8c0d7ad4f1 (patch)
treeb47849e4b433173158a52c58a5c42e50fc5272fa /configs/hermes.nix
parente13ab7360cb42a543480cc45afae3b155b81b03e (diff)
configs/hermes: run hermes as hermes in a tmux, attach as root
The console is root's again. hermes runs as hermes in a tmux started by hermes-tmux.service, and root's login shell attaches to it; detaching gives root's shell back. tmux lets root attach to another user's server. Quitting hermes ends the session, and systemd starts a new one.
Diffstat (limited to 'configs/hermes.nix')
-rw-r--r--configs/hermes.nix31
1 files changed, 24 insertions, 7 deletions
diff --git a/configs/hermes.nix b/configs/hermes.nix
index b963349..2cf40e9 100644
--- a/configs/hermes.nix
+++ b/configs/hermes.nix
@@ -1,8 +1,9 @@
# Hermes Agent (Nous Research), with its own NixOS module, fitted to this
-# guest. Put ANTHROPIC_API_KEY=... into hermes.env in /xchg on the host;
-# run hermes on the console.
-{ config, lib, ... }:
+# guest. Put ANTHROPIC_API_KEY=... into hermes.env in /xchg on the host.
+# hermes runs as hermes in a tmux, which root's console opens.
+{ config, lib, pkgs, ... }:
let
+ tmux = "${pkgs.tmux}/bin/tmux -S /run/hermes/tmux";
# Not a flake input: flake-compat evaluates hermes-agent's flake, with its
# flake.lock, using plain nix. Bump rev and sha256 together.
flake-compat = builtins.fetchTarball {
@@ -32,10 +33,26 @@ in
environmentFiles = [ "/xchg/hermes.env" ];
};
- # The console is hermes', not root's. Its home is stateDir, so hermes
- # there uses the service's state at ~/.hermes.
- services.getty.autologinUser = lib.mkForce "hermes";
- users.users.hermes.packages = [ config.services.hermes-agent.package ];
+ # 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.
+ 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}";
+ Restart = "always";
+ };
+ };
+ # Detaching gets root's shell back.
+ programs.bash.loginShellInit = ''
+ if [ "$USER" = root ] && [ -z "$TMUX" ]; then ${tmux} attach -t hermes; fi
+ '';
# nixos-init doesn't run activation scripts, and that's where the module
# creates the state and installs config.yaml and .env.