feat(nix): add home-manager module for per-user hermes-agent service - #9087
feat(nix): add home-manager module for per-user hermes-agent service#9087yzx9 wants to merge 2 commits into
Conversation
d3464f7 to
d45391d
Compare
6779977 to
3d5f208
Compare
| # Runs hermes-agent as a per-user service under home-manager. | ||
| # Linux: systemd.user.services | ||
| # macOS: launchd.agents | ||
| # Container mode is not supported (requires system-level docker/podman). |
There was a problem hiding this comment.
Not sure if it solves this problem, but Home Manager has options for setting up the colima runtime which might be leveraged for container mode.
There was a problem hiding this comment.
I notices that services.podman might also work. I can proceed with it if this PR can be merged
|
@sunny-g done |
|
@yzx9 any chance you can rebase with the latest version v2026.4.23 (0.11.0)? :) :) |
|
@sunny-g sure |
|
@sunny-g Hi, I’m not using it on Darwin at the moment, but I’m planning to give it a try next week. I regularly rebase to the latest release tag, though since the project is moving quickly, the releases may not always be up to date. I’ll rebase to the main branch as well. In the meantime, I’d suggest copying the first commit into your config, which enables you to integrate Home Manager with the latest Hermes agent. You can refer to yzx9/nix-config as an example. |
|
@yzx9 way ahead of you and appreciate it :), think im just blocked by the python/av installation issues |
|
FYI, I’ve also run into the FFmpeg signing issue on aarch64-darwin with the latest nixpkgs-unstable. It might be related to NixOS/nixpkgs#513225. |
66a52d3 to
d135c7f
Compare
teknium1
left a comment
There was a problem hiding this comment.
Thanks for carrying the Home Manager implementation; current main still lacks this module, so the feature request in #9056 remains valid.
Problems
nix/homeManagerModules.nix:516-524appends every secret file to persistent.envon every service start. That duplicates entries and copies secret-manager output into Hermes state.nix/homeManagerModules.nix:536and:617export deprecatedMESSAGING_CWD. Gateway startup callswarn_deprecated_cwd_env_vars()atgateway/run.py:1702-1703;hermes_cli/config.py:5402-5439requiresterminal.cwdinstead.website/docs/getting-started/nix-setup.md:296overstates parity: the Home Manager module lacks NixOS options declared atnix/nixosModules.nix:481,:502, and:527.- The added checks cover managed-message text only; they do not evaluate
homeManagerModules.default.
Suggested changes
- Use a non-duplicating secret-file design, migrate the working directory to
settings.terminal.cwd, correct or complete the option-parity claim, and add Home Manager module evaluation coverage.
Automated hermes-sweeper review.
| map (f: '' | ||
| if [ -f "${f}" ]; then | ||
| echo "" >> "$ENV_FILE" | ||
| cat "${f}" >> "$ENV_FILE" |
There was a problem hiding this comment.
This runs on every service start, so each restart appends the same secret file again to persistent .env. Please use a non-duplicating secret-file mechanism that also avoids copying secret-manager output into Hermes state.
| if cfg.managedMode == "nixos" then "home-manager-nixos" else "home-manager" | ||
| }" | ||
| "MESSAGING_CWD=${cfg.workingDirectory}" | ||
| ("PATH=" + servicePath + "\${PATH:+:$PATH}") |
There was a problem hiding this comment.
MESSAGING_CWD is deprecated: current gateway startup warns on it and requires terminal.cwd in config instead (gateway/run.py:1702-1703, hermes_cli/config.py:5402-5439). Configure the module's generated settings.terminal.cwd rather than exporting this environment variable.
| } | ||
| ``` | ||
|
|
||
| The `programs.hermes-agent` options are the same as the NixOS module's `services.hermes-agent` options, minus `user`, `group`, `createUser`, `addToSystemPackages`, and `container.*`. |
There was a problem hiding this comment.
This parity claim is inaccurate: the Home Manager module does not define NixOS options extraPlugins, extraPythonPackages, or extraDependencyGroups (nix/nixosModules.nix:481, :502, :527). Please either implement them or document the supported subset.
187197e to
622a28c
Compare
Related: #84178 implements the same Home Manager capability via a shared NixOS/Home Manager module refactor. These are competing approaches; maintainer review should choose the preferred design. |
622a28c to
d05602c
Compare
Adds homeManagerModules.default exposing programs.hermes-agent with the same declarative config, MCP servers, documents, and settings as the NixOS module, but adapted for home-manager's user-scoped architecture: - systemd.user.services or launchd.agents instead of system-level services - State dir defaults to ~/.local/share/hermes (XDG convention) - home.activation for setup, no user/group creation needed sops-nix compatibility: sops-nix decrypts secrets during home.activation, which completes before any services start. No explicit service dependency is needed — ExecStartPre (Linux) and the launchd wrapper (Darwin) find the decrypted files already in place. agenix compatibility: environmentFiles are appended to .env via ExecStartPre (runs after agenix decrypts secrets), not in the activation script. The service unit adds After/Wants on agenix.service when environmentFiles is non-empty.
The home-manager module used HERMES_MANAGED=true identically to the NixOS module, causing incorrect error messages directing users to edit services.hermes-agent.settings and run nixos-rebuild switch. Add managedMode option (home-manager/nixos) to the home-manager module so HERMES_MANAGED now carries the manager identity: - home-manager: standalone (update via home-manager switch) - home-manager-nixos: used as NixOS module (update via nixos-rebuild switch) Also read .managed marker file content for interactive shell detection and add nix flake checks for both modes.
d05602c to
d38dc34
Compare
|
closed as #84178 got merged |
What does this PR do?
Adds homeManagerModules.default exposing programs.hermes-agent with the same declarative config, MCP servers, documents, and settings as the NixOS module, but adapted for home-manager's user-scoped architecture.
Related Issue
Fixes #9056
Type of Change
Changes Made
secret management:
sops-nix compatibility: sops-nix decrypts secrets during
home.activation, which completes before any services start. No explicit service dependency is needed — ExecStartPre (Linux) and the launchd wrapper (Darwin) find the decrypted files already in place.agenix compatibility: environmentFiles are appended to .env via ExecStartPre (runs after agenix decrypts secrets), not in the activation script. The service unit adds After/Wants on agenix.service when environmentFiles is non-empty.
A potential issue is that the secret may have been appended multiple times to the
.envfile. This could be resolved after #10139 is merged.How to Test
inputs.hermes-agent.url = "github:yzx9/hermes-agent/feat/home-manager";cat ~/.local/share/hermes/.hermes/.envChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AFor New Skills
hermes --toolsets skills -q "Use the X skill to do Y"Screenshots / Logs