Skip to content

The agent that grows with you

fix(nix): module extraPythonPackages/extraDependencyGroups extend the package's own

cl0vrfi3ld4d1cf2d0de43
diff --git a/nix/checks.nix b/nix/checks.nix
index 72ab72003c3..51130da5108 100644
--- a/nix/checks.nix
+++ b/nix/checks.nix
@@ -1292,6 +1292,36 @@ 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
+ 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"
+ mkdir -p $out
+ echo "ok" > $out/result
+ '';
+
# Exercise the actual uv2nix environment, not only the selector.
python-lock-derived = pkgs.runCommand "hermes-python-lock-derived" { } ''
set -e
diff --git a/nix/moduleCommon.nix b/nix/moduleCommon.nix
index 5dfeb88ad5f..c718f39a88c 100644
--- a/nix/moduleCommon.nix
+++ b/nix/moduleCommon.nix
@@ -676,12 +676,19 @@ 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.
effectivePackage =
cfg:
if cfg.extraPythonPackages == [ ] && cfg.extraDependencyGroups == [ ] then
cfg.package
else
- cfg.package.override { inherit (cfg) extraPythonPackages extraDependencyGroups; };
+ cfg.package.override (prev: {
+ extraPythonPackages = (prev.extraPythonPackages or [ ]) ++ cfg.extraPythonPackages;
+ extraDependencyGroups = lib.unique ((prev.extraDependencyGroups or [ ]) ++ cfg.extraDependencyGroups);
+ });
# ── The rendered config.yaml ────────────────────────────────────────────
# YAML contains JSON, so the output of toJSON is a correct config.yaml.