fix(nix): upgrade Python 3.11 → 3.12, add cross-platform eval check (#12208)

This commit is contained in:
Siddharth Balyan 2026-04-18 09:21:03 -07:00 committed by GitHub
parent 8a0c774e9e
commit b0efdf37d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 40 additions and 16 deletions

View file

@ -37,7 +37,30 @@ json.dump(sorted(leaf_paths(DEFAULT_CONFIG)), sys.stdout, indent=2)
in { in {
packages.configKeys = configKeys; packages.configKeys = configKeys;
checks = lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux { checks = {
# Cross-platform evaluation — catches "not supported for interpreter"
# errors (e.g. sphinx dropping python311) without needing a darwin builder.
# Evaluation is pure and instant; it doesn't build anything.
cross-eval = let
targetSystems = builtins.filter
(s: inputs.self.packages ? ${s})
[ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ];
tryEvalPkg = sys:
let pkg = inputs.self.packages.${sys}.default;
in builtins.tryEval (builtins.seq pkg.drvPath true);
results = map (sys: { inherit sys; result = tryEvalPkg sys; }) targetSystems;
failures = builtins.filter (r: !r.result.success) results;
failMsg = lib.concatMapStringsSep "\n" (r: " - ${r.sys}") failures;
in pkgs.runCommand "hermes-cross-eval" { } (
if failures != [] then
builtins.throw "Package fails to evaluate on:\n${failMsg}"
else ''
echo "PASS: package evaluates on all ${toString (builtins.length targetSystems)} platforms"
mkdir -p $out
echo "ok" > $out/result
''
);
} // lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
# Verify binaries exist and are executable # Verify binaries exist and are executable
package-contents = pkgs.runCommand "hermes-package-contents" { } '' package-contents = pkgs.runCommand "hermes-package-contents" { } ''
set -e set -e

View file

@ -12,7 +12,7 @@
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
inputsFrom = packages; inputsFrom = packages;
packages = with pkgs; [ packages = with pkgs; [
python311 uv nodejs_22 ripgrep git openssh ffmpeg python312 uv nodejs_22 ripgrep git openssh ffmpeg
]; ];
shellHook = let shellHook = let

View file

@ -148,15 +148,14 @@
su -s /bin/sh "$TARGET_USER" -c 'curl -LsSf https://astral.sh/uv/install.sh | sh' || true su -s /bin/sh "$TARGET_USER" -c 'curl -LsSf https://astral.sh/uv/install.sh | sh' || true
fi fi
# Python 3.11 venv — gives the agent a writable Python with pip. # Python 3.12 venv — gives the agent a writable Python with pip.
# Uses uv to install Python 3.11 (Ubuntu 24.04 ships 3.12).
# --seed includes pip/setuptools so bare `pip install` works. # --seed includes pip/setuptools so bare `pip install` works.
_UV_BIN="$TARGET_HOME/.local/bin/uv" _UV_BIN="$TARGET_HOME/.local/bin/uv"
if [ ! -d "$TARGET_HOME/.venv" ] && [ -x "$_UV_BIN" ]; then if [ ! -d "$TARGET_HOME/.venv" ] && [ -x "$_UV_BIN" ]; then
su -s /bin/sh "$TARGET_USER" -c " su -s /bin/sh "$TARGET_USER" -c "
export PATH=\"\$HOME/.local/bin:\$PATH\" export PATH=\"\$HOME/.local/bin:\$PATH\"
uv python install 3.11 uv python install 3.12
uv venv --python 3.11 --seed \"\$HOME/.venv\" uv venv --python 3.12 --seed \"\$HOME/.venv\"
" || true " || true
fi fi

View file

@ -87,7 +87,7 @@
STAMP_VALUE="${pyprojectHash}:${uvLockHash}" STAMP_VALUE="${pyprojectHash}:${uvLockHash}"
if [ ! -f "$STAMP" ] || [ "$(cat "$STAMP")" != "$STAMP_VALUE" ]; then if [ ! -f "$STAMP" ] || [ "$(cat "$STAMP")" != "$STAMP_VALUE" ]; then
echo "hermes-agent: installing Python dependencies..." echo "hermes-agent: installing Python dependencies..."
uv venv .venv --python ${pkgs.python311}/bin/python3 2>/dev/null || true uv venv .venv --python ${pkgs.python312}/bin/python3 2>/dev/null || true
source .venv/bin/activate source .venv/bin/activate
uv pip install -e ".[all]" uv pip install -e ".[all]"
[ -d mini-swe-agent ] && uv pip install -e ./mini-swe-agent 2>/dev/null || true [ -d mini-swe-agent ] && uv pip install -e ./mini-swe-agent 2>/dev/null || true

View file

@ -1,6 +1,6 @@
# nix/python.nix — uv2nix virtual environment builder # nix/python.nix — uv2nix virtual environment builder
{ {
python311, python312,
lib, lib,
callPackage, callPackage,
uv2nix, uv2nix,
@ -51,28 +51,30 @@ let
pythonPackageOverrides = final: _prev: pythonPackageOverrides = final: _prev:
if isAarch64Darwin then { if isAarch64Darwin then {
numpy = mkPrebuiltOverride final python311.pkgs.numpy { }; numpy = mkPrebuiltOverride final python312.pkgs.numpy { };
av = mkPrebuiltOverride final python311.pkgs.av { }; pyarrow = mkPrebuiltOverride final python312.pkgs.pyarrow { };
humanfriendly = mkPrebuiltOverride final python311.pkgs.humanfriendly { }; av = mkPrebuiltOverride final python312.pkgs.av { };
coloredlogs = mkPrebuiltOverride final python311.pkgs.coloredlogs { humanfriendly = mkPrebuiltOverride final python312.pkgs.humanfriendly { };
coloredlogs = mkPrebuiltOverride final python312.pkgs.coloredlogs {
humanfriendly = [ ]; humanfriendly = [ ];
}; };
onnxruntime = mkPrebuiltOverride final python311.pkgs.onnxruntime { onnxruntime = mkPrebuiltOverride final python312.pkgs.onnxruntime {
coloredlogs = [ ]; coloredlogs = [ ];
numpy = [ ]; numpy = [ ];
packaging = [ ]; packaging = [ ];
}; };
ctranslate2 = mkPrebuiltOverride final python311.pkgs.ctranslate2 { ctranslate2 = mkPrebuiltOverride final python312.pkgs.ctranslate2 {
numpy = [ ]; numpy = [ ];
pyyaml = [ ]; pyyaml = [ ];
}; };
faster-whisper = mkPrebuiltOverride final python311.pkgs.faster-whisper { faster-whisper = mkPrebuiltOverride final python312.pkgs.faster-whisper {
av = [ ]; av = [ ];
ctranslate2 = [ ]; ctranslate2 = [ ];
huggingface-hub = [ ]; huggingface-hub = [ ];
@ -84,7 +86,7 @@ let
pythonSet = pythonSet =
(callPackage pyproject-nix.build.packages { (callPackage pyproject-nix.build.packages {
python = python311; python = python312;
}).overrideScope }).overrideScope
(lib.composeManyExtensions [ (lib.composeManyExtensions [
pyproject-build-systems.overlays.default pyproject-build-systems.overlays.default