Skip to content

The agent that grows with you

fix(nix): keep shipped dependency groups out of extraDependencyGroups

cl0vrfi3lddb752fb8c47b
diff --git a/nix/checks.nix b/nix/checks.nix
index 51130da5108..2afdbb6307b 100644
--- a/nix/checks.nix
+++ b/nix/checks.nix
@@ -1292,32 +1292,65 @@ json.dump(sorted(leaf_paths(DEFAULT_CONFIG)), sys.stdout, indent=2)
echo "ok" > $out/result
'';
- # The module's extraPythonPackages / extraDependencyGroups extend the
- # selected package's own lists. The default package is `minimal` plus
- # the provider groups (anthropic, ...); a replacing override silently
- # rebuilt it as `minimal` the moment a plugin was added. Eval-only:
- # the venv drvPath is the identity of the dependency set.
- module-extras-extend-package = let
+ # Extras ADD to what a package ships, through both entry points:
+ # `pkgs.hermes-agent.override { ... }` (the documented overlay path)
+ # and the modules' extraPythonPackages / extraDependencyGroups.
+ # Replacing semantics rebuilt the default package as `minimal` and
+ # dropped every provider group. Each case asserts a positive effect
+ # AND a preserved one, so an implementation that ignored the extras
+ # fails too. Eval-only: a drvPath is the identity of what it builds.
+ extras-extend-package = let
testPkg = pythonLock.interpreter.pkgs.pyfiglet;
- venvOf = settings: builtins.unsafeDiscardStringContext
- (evalHomeModule ({ enable = true; } // settings)).config.programs.hermes-agent.package.hermesVenv.drvPath;
- defaultVenv = builtins.unsafeDiscardStringContext hermesVenv.drvPath;
- withPlugin = venvOf { extraPythonPackages = [ testPkg ]; };
- withGroup = venvOf { extraDependencyGroups = [ "anthropic" ]; };
- in pkgs.runCommand "hermes-module-extras-extend-package" { } ''
- set -e
- echo "=== Checking module extras extend the package's own ==="
- if [ "${withPlugin}" != "${defaultVenv}" ]; then
- echo "FAIL: extraPythonPackages changed the sealed venv (default groups dropped)"
- echo " default: ${defaultVenv}"
- echo " module: ${withPlugin}"
- exit 1
- fi
- echo "PASS: extraPythonPackages keeps the default package's venv"
- if [ "${withGroup}" != "${defaultVenv}" ]; then
- echo "FAIL: a group already in the package rebuilt the venv"; exit 1
- fi
- echo "PASS: extraDependencyGroups merges with the package's groups"
+ # Not in the default package's groups, so adding it must show.
+ newGroup = "langfuse";
+ path = drv: builtins.unsafeDiscardStringContext drv.drvPath;
+ modulePackage = settings:
+ (evalHomeModule ({ enable = true; } // settings)).config.programs.hermes-agent.package;
+
+ viaModulePlugin = modulePackage { extraPythonPackages = [ testPkg ]; };
+ viaModuleGroup = modulePackage { extraDependencyGroups = [ newGroup ]; };
+ viaModuleShipped = modulePackage { extraDependencyGroups = [ "anthropic" ]; };
+ viaOverlayGroup = hermes-agent.override { extraDependencyGroups = [ newGroup ]; };
+ viaFunctionGroup = hermes-agent.override (prev: {
+ extraDependencyGroups = (prev.extraDependencyGroups or [ ]) ++ [ newGroup ];
+ });
+ viaOverlayShipped = hermes-agent.override { extraDependencyGroups = [ "messaging" ]; };
+
+ cases = [
+ {
+ what = "module extraPythonPackages reaches the package (wrapper PYTHONPATH)";
+ ok = path viaModulePlugin != path hermes-agent;
+ }
+ {
+ what = "module extraPythonPackages keeps the default sealed venv";
+ ok = path viaModulePlugin.hermesVenv == path hermesVenv;
+ }
+ {
+ what = "a new group changes the venv (not ignored)";
+ ok = path viaFunctionGroup.hermesVenv != path hermesVenv;
+ }
+ {
+ what = "module extraDependencyGroups == appending to the package's own";
+ ok = path viaModuleGroup.hermesVenv == path viaFunctionGroup.hermesVenv;
+ }
+ {
+ what = "overlay attrset override == appending (shipped groups survive)";
+ ok = path viaOverlayGroup.hermesVenv == path viaFunctionGroup.hermesVenv;
+ }
+ {
+ what = "module group the package already ships leaves the venv unchanged";
+ ok = path viaModuleShipped.hermesVenv == path hermesVenv;
+ }
+ {
+ what = "overlay group the package already ships leaves the venv unchanged";
+ ok = path viaOverlayShipped.hermesVenv == path hermesVenv;
+ }
+ ];
+ report = lib.concatMapStrings (c: "${if c.ok then "PASS" else "FAIL"}: ${c.what}\n") cases;
+ in pkgs.runCommand "hermes-extras-extend-package" { inherit report; } ''
+ echo "=== Checking extras extend the package's own ==="
+ printf '%s' "$report"
+ if printf '%s' "$report" | grep -q '^FAIL'; then exit 1; fi
mkdir -p $out
echo "ok" > $out/result
'';
diff --git a/nix/hermes-agent.nix b/nix/hermes-agent.nix
index 88b92b511fc..56cdf81d842 100644
--- a/nix/hermes-agent.nix
+++ b/nix/hermes-agent.nix
@@ -4,6 +4,9 @@
# Users override via:
# pkgs.hermes-agent.override { extraPythonPackages = [...]; }
# pkgs.hermes-agent.override { extraDependencyGroups = [ "honcho" ]; }
+# Both extras add to what the package ships. The shipped groups live in
+# defaultDependencyGroups (set by packages.nix for `full`/`messaging`), so a
+# plain override of the extras never drops them.
{
lib,
stdenv,
@@ -40,6 +43,9 @@
version ? "0.0.0",
distance ? 0,
extraPythonPackages ? [ ],
+ # The optional groups this variant ships; packages.nix owns the lists.
+ defaultDependencyGroups ? [ ],
+ # The user's additions on top of defaultDependencyGroups.
extraDependencyGroups ? [ ],
}:
let
@@ -48,6 +54,8 @@ let
pythonLock = callPackage ./pythonLock.nix { };
python = pythonLock.interpreter;
+ packageDependencyGroups = defaultDependencyGroups ++ extraDependencyGroups;
+
# Install stamp values — written to install-stamp.json so the Python
# runtime (CLI, TUI) reads one file instead of env vars or .git probes.
stampDistance =
@@ -79,14 +87,16 @@ let
});
mkHermesVenv =
- extraDependencyGroups:
+ groups:
callPackage ./python.nix {
inherit uv2nix pyproject-nix pyproject-build-systems;
pythonSrc = hermesNpmLib.pythonSrc;
- dependency-groups = [ "all" ] ++ extraDependencyGroups;
+ # Deduplicated so naming a group the variant already ships leaves the
+ # venv derivation unchanged.
+ dependency-groups = lib.unique ([ "all" ] ++ groups);
};
- hermesVenv = (mkHermesVenv extraDependencyGroups).venv;
+ hermesVenv = (mkHermesVenv packageDependencyGroups).venv;
pmRuntime = callPackage ./pm-runtime.nix {
inherit uv2nix pyproject-nix pyproject-build-systems;
@@ -302,7 +312,7 @@ stdenv.mkDerivation (finalAttrs: {
passthru =
let
- devPython = (mkHermesVenv (extraDependencyGroups ++ [ "dev" ])).editableVenv;
+ devPython = (mkHermesVenv (packageDependencyGroups ++ [ "dev" ])).editableVenv;
in
{
inherit
diff --git a/nix/moduleCommon.nix b/nix/moduleCommon.nix
index c718f39a88c..ccf813c29dc 100644
--- a/nix/moduleCommon.nix
+++ b/nix/moduleCommon.nix
@@ -676,10 +676,11 @@ let
'';
# ── Package resolution ──────────────────────────────────────────────────
- # The module's lists extend the package's own, never replace them: the
- # default package is itself `minimal.override { extraDependencyGroups =
- # [ "anthropic" ... ]; }`, so a plain attrset override would drop every
- # provider group the moment a plugin is added.
+ # The module's lists extend the package's own extras, never replace them.
+ # The shipped variants keep their groups in defaultDependencyGroups, but a
+ # custom `package` built with `.override { extraDependencyGroups = ...; }`
+ # carries its choices in the extras, and a plain attrset override here
+ # would drop them.
effectivePackage =
cfg:
if cfg.extraPythonPackages == [ ] && cfg.extraDependencyGroups == [ ] then
@@ -687,7 +688,7 @@ let
else
cfg.package.override (prev: {
extraPythonPackages = (prev.extraPythonPackages or [ ]) ++ cfg.extraPythonPackages;
- extraDependencyGroups = lib.unique ((prev.extraDependencyGroups or [ ]) ++ cfg.extraDependencyGroups);
+ extraDependencyGroups = (prev.extraDependencyGroups or [ ]) ++ cfg.extraDependencyGroups;
});
# ── The rendered config.yaml ────────────────────────────────────────────
diff --git a/nix/packages.nix b/nix/packages.nix
index b1120a9b1f3..616dc37f8f7 100644
--- a/nix/packages.nix
+++ b/nix/packages.nix
@@ -45,9 +45,11 @@
;
};
- # All platform-portable optional integrations pre-built.
+ # All platform-portable optional integrations pre-built. These are the
+ # variant's own groups, not the user's extras, so an
+ # `.override { extraDependencyGroups = ...; }` adds to them.
full = minimal.override {
- extraDependencyGroups = [
+ defaultDependencyGroups = [
"anthropic"
"azure-identity"
"bedrock"
@@ -86,7 +88,7 @@
# `nix profile install .#messaging` connects to Discord/Telegram/Slack
# on first run — lazy-install can't write to the read-only /nix/store.
messaging = minimal.override {
- extraDependencyGroups = [ "messaging" ];
+ defaultDependencyGroups = [ "messaging" ];
};
tui = full.hermesTui;