fix(nix): the dev shell keeps hermes as the installed Hermes
The dev shell put the checkout's launcher and the dev venv's console scripts ahead of the user's install on PATH, so running Hermes from any checkout or worktree ran that checkout instead. The project commands now live in the dev venv's libexec, and `hermes-checkout` runs the checkout explicitly. The libexec name stays `hermes`, so gateway identity and relaunch keep working.
This commit is contained in:
committed by
Siddharth Balyan
parent
6ca9fc5c61
commit
8ad89d45ac
2
.envrc
2
.envrc
@@ -1,4 +1,4 @@
|
||||
watch_file flake.nix flake.lock hermes pyproject.toml uv.lock
|
||||
watch_file flake.nix flake.lock pyproject.toml uv.lock
|
||||
watch_file pnpm-lock.yaml pnpm-workspace.yaml package.json web/package.json ui-tui/package.json website/package.json apps/shared/package.json apps/desktop/package.json ui-tui/packages/hermes-ink/package.json
|
||||
watch_dir nix
|
||||
watch_dir pm
|
||||
|
||||
@@ -23,10 +23,6 @@
|
||||
{
|
||||
devShells.default = pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
(pkgs.runCommand "hermes" { } ''
|
||||
mkdir -p $out/bin
|
||||
install -Dm755 ${../hermes} $out/bin/hermes
|
||||
'')
|
||||
self'.packages.sandbox
|
||||
]
|
||||
# Wayland-only: cage and ghostty pull alsa-lib, which does not
|
||||
@@ -62,7 +58,7 @@
|
||||
export NIX_SSL_CERT_FILE="$SSL_CERT_FILE"
|
||||
|
||||
echo "Hermes Agent dev shell in $HERMES_PYTHON_SRC_ROOT"
|
||||
echo "Ready. Run 'hermes' or 'sandbox hermes' to start."
|
||||
echo "Ready. 'hermes-checkout' runs this checkout; 'hermes' stays your installed Hermes."
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
@@ -351,8 +351,11 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
# 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.
|
||||
# The project's own commands (`hermes`, ...) go to libexec, off PATH, so
|
||||
# the dev shell never hides the installed Hermes; `hermes-checkout` runs them.
|
||||
projectCommands = builtins.attrNames (lib.importTOML ../pyproject.toml).project.scripts;
|
||||
devVenv = runCommand "hermes-agent-dev-venv" { } ''
|
||||
mkdir -p $out/bin $out/lib/python${python.pythonVersion}
|
||||
mkdir -p $out/bin $out/libexec/hermes-checkout $out/lib/python${python.pythonVersion}
|
||||
ln -s ${devPython}/${sitePackagesPath} $out/${sitePackagesPath}
|
||||
cat > $out/pyvenv.cfg <<EOF
|
||||
home = ${pmPython}/bin
|
||||
@@ -371,13 +374,20 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
[ -e "$out/bin/$name" ] && continue
|
||||
case "$name" in activate*|Activate*) continue ;; esac
|
||||
[ "$(readlink -f "$script")" = "$devInterpreter" ] && continue
|
||||
case " ${lib.concatStringsSep " " projectCommands} " in
|
||||
*" $name "*) dir=$out/libexec/hermes-checkout ;;
|
||||
*) dir=$out/bin ;;
|
||||
esac
|
||||
if head -n1 "$script" | grep -q '^#!.*python'; then
|
||||
{ echo "#!$out/bin/python3"; tail -n +2 "$script"; } > "$out/bin/$name"
|
||||
chmod +x "$out/bin/$name"
|
||||
{ echo "#!$out/bin/python3"; tail -n +2 "$script"; } > "$dir/$name"
|
||||
chmod +x "$dir/$name"
|
||||
else
|
||||
ln -s "$script" "$out/bin/$name"
|
||||
ln -s "$script" "$dir/$name"
|
||||
fi
|
||||
done
|
||||
# The libexec name stays `hermes`: process identity and relaunch read argv[0].
|
||||
printf '#!/bin/sh\nexec %s "$@"\n' "$out/libexec/hermes-checkout/hermes" > $out/bin/hermes-checkout
|
||||
chmod +x $out/bin/hermes-checkout
|
||||
'';
|
||||
|
||||
pm = writeShellApplication {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
# Electron needs its native runtime libraries on LD_LIBRARY_PATH when the
|
||||
# sandboxed command launches the desktop app (`sandbox hermes desktop`,
|
||||
# sandboxed command launches the desktop app (`sandbox hermes-checkout desktop`,
|
||||
# `sandbox pnpm run dev`); nothing else in the sandbox is nix-specific.
|
||||
alsa-lib,
|
||||
at-spi2-atk,
|
||||
|
||||
@@ -94,7 +94,7 @@ The `default` package adds ~700 MB to the closure. If you only need messaging pl
|
||||
git clone https://github.com/NousResearch/hermes-agent.git
|
||||
cd hermes-agent
|
||||
nix develop
|
||||
hermes setup
|
||||
hermes-checkout setup
|
||||
```
|
||||
|
||||
</details>
|
||||
@@ -940,12 +940,17 @@ and it needs no `PYTHONPATH`. It does not install
|
||||
Python dependencies into a repository-local `.venv`. The shell also provides
|
||||
Node.js and runtime tools. Its pnpm hook refreshes JS workspaces when their inputs change.
|
||||
|
||||
The shell does not change which `hermes` runs. `hermes` stays your installed Hermes, so you
|
||||
can keep using it while you work on the checkout. `hermes-checkout` runs this checkout's code
|
||||
and takes the same arguments. Give it a separate `HERMES_HOME` when a change touches stored
|
||||
state, because both commands read the same one by default.
|
||||
|
||||
```bash
|
||||
cd hermes-agent
|
||||
nix develop
|
||||
"$HERMES_PYTHON" -c "import sys; print(sys.executable); print(sys.version)"
|
||||
hermes setup
|
||||
hermes chat
|
||||
hermes-checkout --version
|
||||
HERMES_HOME="$PWD/.scratch/home" hermes-checkout chat
|
||||
```
|
||||
|
||||
### direnv (Recommended)
|
||||
|
||||
Reference in New Issue
Block a user