Hermes
The services.hermes service module enables the Hermes Agent AI framework on a NixOS host using the Google Gemini native provider.
Architecture
To understand how Hermes operates on NixOS:
-
CLI (
hermes chat,hermes --tui): Hermes CLI is a standalone application (not a thin RPC client). When invoked in a terminal, it executes in-process, loadsconfig.yamland.envfrom$HERMES_HOME, manages local SQLite databases (state.db,projects.db, memories, session history), and makes outbound HTTPS requests directly to the configured LLM API (Google Gemini). -
System Service (
hermes-agent.serviceGateway): The background systemd service runshermes gateway run. The Gateway is Hermes' multi-channel messaging bridge (for connecting bots to Telegram, Discord, Slack, WhatsApp, Matrix, etc.). It listens for external chat platform events and runs background agent loops. -
State & Permissions (
/var/lib/hermes/.hermes): Under the NixOS system service module: - The daemon runs as system user
hermes:hermes. - System state, database, and declarative config live in
/var/lib/hermes/.hermes(mode2770). - When
addToSystemPackages = trueis enabled,HERMES_HOMEis set to/var/lib/hermes/.hermesso the CLI shares skills, memories, and cron sessions with the gateway service. - Interactive users (e.g.
vorburger) must be members of thehermesgroup to read/write shared configuration and SQLite databases without permission errors.
Alternatives
- System Module (Current):
Uses upstream
inputs.hermes-agent.nixosModules.default. Best for headless servers or systems running persistent messaging gateways (Telegram, Discord, Slack) where interactive users share gateway state via thehermesgroup. - Home Manager Module (
homeManagerModules.default): Upstream also provides a user-level Home Manager module. It manages Hermes purely inside the user's home directory (~/.hermes) with0600/0700permissions and optionalsystemd.user.services.hermes-agentfor the gateway. This isolates state per user without requiring system users or shared groups. - Standalone CLI Package:
If the background gateway service is not needed at all, the package can be installed standalone (
inputs.hermes-agent.packages.${pkgs.system}.default) without activating any systemd services.
Configuration
Enable the service in your host configuration (e.g. titan.nix):
services.hermes.enable = true;
When enabled, this service automatically:
- Configures and starts the native Hermes systemd service (
services.hermes-agent) configured to use Google Gemini (gemini-flash-latestathttps://generativelanguage.googleapis.com/v1beta). - Integrates the RTK (Rust Token Killer) CLI proxy (
pkgs.rtk) andrtk-hermesplugin (rtk-rewrite) to intercept and compress shell command outputs (saving 60–90% LLM tokens on terminal outputs). - Integrates the
hermes-lcm(Lossless Context Management) plugin (context.engine = "lcm"), providing SQLite DAG-backed bounded context management with agent recall tools (lcm_grep,lcm_expand,lcm_recall,lcm_recent, etc.), with built-in context compression configured as a fallback. - Routes session title generation (
auxiliary.title_generation) to localgemma4:e2bvia Ollama (http://localhost:11434/v1) for fast, local-first session summarization. - Binds the encrypted API key secret
/run/secrets/hermes(secrets/encrypted/hermes.age) into the Hermes environment. - Adds user
vorburgerto thehermesgroup and setsHERMES_HOME = "/var/lib/hermes/.hermes"so interactive shells and the CLI use the system configuration and shared state. - Installs the
hermesCLI into system packages (addToSystemPackages = true) and sets thehshell alias tohermes.
Secrets
Hermes requires a Google Gemini API key from Google AI Studio.
To edit or update the encrypted secret:
ragenix -e secrets/encrypted/hermes.age
The file format should be:
GOOGLE_API_KEY=AIzaSy...