From 56e3ea2ca63b86aced84657042266eb318d096c6 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 20 Nov 2026 03:25:52 +0000 Subject: configs/hermes: use the Claude subscription through claude Replace the anthropic provider, with its API key from /xchg, by the Claude Subscription DirectSDK plugin from hermes-official-plugins. It runs each turn through the claude CLI, from nixpkgs' claude-code, and has no credentials of its own: log in once with claude auth login as hermes, e.g. in a new window of the tmux. The login goes to ~/.claude, i.e. into stateDir, so it lasts as long as the rest of the state. The plugin needs Hermes 0.21.4, or main from 118984d7a02f on, which the pinned revision includes. --- configs/hermes.nix | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'configs') diff --git a/configs/hermes.nix b/configs/hermes.nix index 66b1094..395414e 100644 --- a/configs/hermes.nix +++ b/configs/hermes.nix @@ -1,6 +1,7 @@ # 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. -# hermes runs as hermes in a tmux, which root's console opens. +# guest. hermes runs as hermes in a tmux, which root's console opens. It +# uses the Claude subscription through the claude CLI: log in once with +# claude auth login, in a new window there (C-b c). { config, lib, pkgs, ... }: let tmux = "${pkgs.tmux}/bin/tmux -S /run/hermes/tmux"; @@ -72,12 +73,21 @@ in # like nix's database, see /nix/var. stateDir = "/nix/.rw-store/hermes"; settings.model = { - provider = "anthropic"; - default = "claude-opus-5-5"; + provider = "claude-subscription-directsdk-experimental"; + default = "opus"; }; - # Read at boot; a missing file only gets a warning. - environmentFiles = [ "/xchg/hermes.env" ]; + extraPlugins = [ + (pkgs.runCommand "claude-subscription-directsdk" { } '' + cp -r ${builtins.fetchTarball { + url = "https://github.com/NousResearch/hermes-official-plugins/archive/80025332933bf84fb3c7b68f369d9fe59a771e98.tar.gz"; + sha256 = "1ivgwfqnhgpwsp204ljsm4jwcq00n8zs4pd5dgyx0crb3hdig3bq"; + }}/claude-subscription-directsdk $out + '') + ]; + # The login is in ~/.claude, i.e. in stateDir. + extraPackages = [ pkgs.claude-code ]; }; + 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 @@ -94,6 +104,7 @@ in ExecStart = "${tmux} new-session -d -s hermes ${lib.getExe config.services.hermes-agent.package}"; Restart = "always"; }; + inherit (config.systemd.services.hermes-agent) path; }; # Detaching gets root's shell back. programs.bash.loginShellInit = '' @@ -101,11 +112,11 @@ in ''; # The module adds pkgs.git, which needs perl; the package has gitMinimal. - systemd.services.hermes-agent.path = lib.mkForce [ + systemd.services.hermes-agent.path = lib.mkForce ([ config.services.hermes-agent.package pkgs.bash pkgs.coreutils - ]; + ] ++ config.services.hermes-agent.extraPackages); # nixos-init doesn't run activation scripts, and that's where the module # creates the state and installs config.yaml and .env. -- cgit v1.3.1