A NixOS module (nix/hermes-guest.nix) layers confinement on upstream's services.hermes-agent: no network (PrivateNetwork), an empty /run with two Unix sockets bound back in, and no user manager. Hermes reaches the world through host.sock, the guest's Endo methods (listMessages, request, lookup, reply, ...) as MCP, and llm.sock, an inference proxy that holds the API key. The same unit runs on a Linux host (nix/linux-host.nix) and in a vfkit microVM on macOS (nix/vfkit-vm.nix), where systemd relays the two sockets over vsock to launchd on the host (nix/darwin-host.nix). test/demo.py runs unmodified Hermes against a fake host and a scripted model, and checks what the host received. Generated-by: Claude Opus 5.5
102 lines
2.8 KiB
Nix
102 lines
2.8 KiB
Nix
{
|
|
description = "Hermes, confined to act only as one toybox guest: a systemd unit on Linux, the same unit in a microVM on macOS";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
microvm = {
|
|
url = "github:microvm-nix/microvm.nix";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
# its own nixpkgs: its fixed-output hashes (pnpm deps) are for its pnpm
|
|
hermes-agent.url = "github:NousResearch/hermes-agent";
|
|
};
|
|
|
|
outputs =
|
|
{
|
|
self,
|
|
nixpkgs,
|
|
microvm,
|
|
hermes-agent,
|
|
}:
|
|
let
|
|
inherit (nixpkgs) lib;
|
|
in
|
|
{
|
|
nixosModules = {
|
|
# the unit that ports; whoever imports it serves its two sockets
|
|
hermes-guest = {
|
|
imports = [
|
|
hermes-agent.nixosModules.default
|
|
./nix/hermes-guest.nix
|
|
];
|
|
};
|
|
# a Linux host: the unit, and the inference proxy, under the host's systemd
|
|
linux-host = {
|
|
imports = [
|
|
self.nixosModules.hermes-guest
|
|
./nix/linux-host.nix
|
|
];
|
|
};
|
|
# the macOS VM's NixOS: the unit, with its sockets relayed over vsock
|
|
vfkit-vm = {
|
|
imports = [
|
|
microvm.nixosModules.microvm
|
|
self.nixosModules.hermes-guest
|
|
./nix/vfkit-vm.nix
|
|
];
|
|
};
|
|
};
|
|
|
|
lib = {
|
|
/**
|
|
The macOS VM and its launchd agents, for one person's settings.
|
|
hostDir: where the VM's state image and host sockets live.
|
|
The toybox socket, hostDir/toybox.sock, is toybox's to serve.
|
|
*/
|
|
mkDarwin =
|
|
{
|
|
hostDir,
|
|
model,
|
|
upstream,
|
|
keyFile,
|
|
system ? "aarch64-darwin",
|
|
}:
|
|
let
|
|
hostPkgs = nixpkgs.legacyPackages.${system};
|
|
vm = lib.nixosSystem {
|
|
system = lib.replaceString "-darwin" "-linux" system;
|
|
modules = [
|
|
self.nixosModules.vfkit-vm
|
|
{
|
|
microvm.vmHostPackages = hostPkgs;
|
|
services.hermes-guest = {
|
|
enable = true;
|
|
inherit model;
|
|
vm.hostDir = hostDir;
|
|
};
|
|
}
|
|
];
|
|
};
|
|
runner = vm.config.microvm.declaredRunner;
|
|
in
|
|
{
|
|
inherit vm runner;
|
|
host = import ./nix/darwin-host.nix {
|
|
pkgs = hostPkgs;
|
|
inherit
|
|
lib
|
|
runner
|
|
hostDir
|
|
upstream
|
|
keyFile
|
|
;
|
|
};
|
|
};
|
|
};
|
|
|
|
formatter = lib.genAttrs [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ] (
|
|
system: nixpkgs.legacyPackages.${system}.nixfmt
|
|
);
|
|
};
|
|
}
|