Skip to content

The agent that grows with you

Merge origin/main into fix/nix-extrapythonpkgs-extend

Teknium1de96a025fb8
diff --cc nix/hermes-agent.nix
index 6643ed1f64b,1e8ac517929..df92bc2ce69
--- a/nix/hermes-agent.nix
+++ b/nix/hermes-agent.nix
@@@ -68,25 -68,27 +76,27 @@@ le
version;
# CLI and Electron consume the same provenance and update owner.
- installStampFile = writeText "hermes-install-stamp.json" (builtins.toJSON {
- schemaVersion = 2;
- commit = rev;
- commitDate = lastModified;
- inherit branch dirty;
- builtAt = null;
- baseVersion = version;
- displayVersion = stampDisplayVersion;
- distance = stampDistance;
- source = "nix";
- distribution = "nix";
- pmRuntime = toString pmRuntime;
- updateMechanism = "external";
- payload = "bootstrap";
- tag = null;
- });
+ installStampFile = writeText "hermes-install-stamp.json" (
+ builtins.toJSON {
+ schemaVersion = 2;
+ commit = rev;
+ commitDate = lastModified;
+ inherit branch dirty;
+ builtAt = null;
+ baseVersion = version;
+ displayVersion = stampDisplayVersion;
+ distance = stampDistance;
+ source = "nix";
+ distribution = "nix";
+ pmRuntime = toString pmRuntime;
+ updateMechanism = "external";
+ payload = "bootstrap";
+ tag = null;
+ }
+ );
mkHermesVenv =
- extraDependencyGroups:
+ groups:
callPackage ./python.nix {
inherit uv2nix pyproject-nix pyproject-build-systems;
pythonSrc = hermesNpmLib.pythonSrc;
@@@ -310,7 -326,52 +336,52 @@@ stdenv.mkDerivation (finalAttrs:
passthru =
let
+ # uv2nix builds the editable venv against the nixpkgs interpreter (it
+ # cannot build against a tarball one); devVenv re-homes it onto the
+ # interpreter pm/lock.json pins.
- devPython = (mkHermesVenv (extraDependencyGroups ++ [ "dev" ])).editableVenv;
+ devPython = (mkHermesVenv (packageDependencyGroups ++ [ "dev" ])).editableVenv;
+ pmPython = pmPackages.python;
+
+ # A real venv: pyvenv.cfg's `home` is the pinned interpreter and its
+ # site-packages are devPython's, so `.pth` files (the editable checkout)
+ # load and nothing depends on the caller's PYTHONPATH. Console scripts
+ # are re-shebanged onto it so `pytest` and `python -m pytest` agree.
+ devVenv = runCommand "hermes-agent-dev-venv" { } ''
+ mkdir -p $out/bin $out/lib/python${python.pythonVersion}
+ ln -s ${devPython}/${sitePackagesPath} $out/${sitePackagesPath}
+ cat > $out/pyvenv.cfg <<EOF
+ home = ${pmPython}/bin
+ include-system-site-packages = false
+ version = ${lib.head (lib.splitString "+" pmPython.version)}
+ EOF
+ for name in python python3 python${python.pythonVersion}; do
+ ln -s ${pmPython}/bin/python3 $out/bin/$name
+ done
+ # Every other command carries over: Python scripts re-shebanged onto
+ # this venv, native ones (ruff, ty) linked as-is. The activate scripts
+ # and devPython's own interpreter links would point back at devPython.
+ devInterpreter=$(readlink -f ${devPython}/bin/python3)
+ for script in ${devPython}/bin/*; do
+ name=$(basename "$script")
+ [ -e "$out/bin/$name" ] && continue
+ case "$name" in activate*|Activate*) continue ;; esac
+ [ "$(readlink -f "$script")" = "$devInterpreter" ] && continue
+ if head -n1 "$script" | grep -q '^#!.*python'; then
+ { echo "#!$out/bin/python3"; tail -n +2 "$script"; } > "$out/bin/$name"
+ chmod +x "$out/bin/$name"
+ else
+ ln -s "$script" "$out/bin/$name"
+ fi
+ done
+ '';
+
+ pm = writeShellApplication {
+ name = "pm";
+ text = ''
+ cd "$(git rev-parse --show-toplevel)"
+ exec ${devVenv}/bin/python3 -m pm.cli "$@"
+ '';
+ };
in
{
inherit