Skip to content

fix(image): provide FHS loader + lib path for manylinux wheels - #744

Merged
c-vigo merged 3 commits into
feature/625-nix-claude-migrationfrom
bugfix/736-manylinux-loader
Jun 29, 2026
Merged

c-vigo merged 3 commits into
feature/625-nix-claude-migrationfrom
bugfix/736-manylinux-loader

Conversation

@c-vigo

@c-vigo c-vigo commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

The pure-Nix image (Nix-but-not-NixOS) could not run pre-compiled PyPI (manylinux) wheels installed at runtime. Two gaps:

  1. No FHS dynamic loader /lib64/ld-linux-x86-64.so.2 (the PT_INTERP every manylinux x86_64 wheel hardcodes) — standalone PyPI tools (consumer pre-commit ruff/typos) aborted with cannot execute: required file not found.
  2. The Nix C++/compression runtime (libstdc++/libgcc_s/libz) was off the loader path — C extensions dlopened by the baked CPython (numpy/scipy, pre-commit pymarkdown's pyjson5) failed with ImportError: libstdc++.so.6.

Fix

  • Bootstrap layer: symlink the Nix glibc loader to /lib64/ld-linux-x86-64.so.2 (newer glibc runs old-glibc wheels via backward compatibility).
  • config.Env: bake LD_LIBRARY_PATH = makeLibraryPath [ stdenv.cc.cc.lib zlib ].

The loader symlink fixes standalone wheel executables; LD_LIBRARY_PATH fixes the C-extension .so files dlopened by the store CPython, which never traverse /lib64 (so the loader symlink alone is insufficient). This is the image-scope analogue of the dev-shell #698 fix, but ungated: an all-Nix container has no foreign FHS host binaries to pollute, so the /etc/NIXOS ABI gate from #698/#703 never applies. nix-ld was evaluated but is redundant here — the mandatory global LD_LIBRARY_PATH (needed for the dlopen path nix-ld cannot intercept) already lets a plain glibc-loader symlink cover the standalone-executable case, with a smaller closure.

Verification

Built :test-736, then inside the image:

  • ls -l /lib64/ld-linux-x86-64.so.2 → symlink to the Nix glibc loader ✓
  • numpy 2.5.0 imports (manylinux wheel, C-ext dlopen) ✓
  • pyjson5 OK (the exact pre-commit pymarkdown failure) ✓
  • PyPI ruff 0.15.20 runs (standalone manylinux executable via the /lib64 loader) ✓
  • pytest tests/test_image.py::TestManylinuxRuntime → 3 passed

New tests/test_image.py::TestManylinuxRuntime asserts the loader exists (unconditional) and that numpy/pyjson5 wheels import under the baked CPython (network-guarded, skips offline).

Closes #736

c-vigo added 3 commits June 29, 2026 12:43
Add TestManylinuxRuntime to tests/test_image.py: an unconditional
assertion that /lib64/ld-linux-x86-64.so.2 exists, plus a
network-guarded check that numpy and pyjson5 manylinux wheels import
under the baked CPython. Red against the current image, which ships no
FHS loader nor C++ runtime on the loader path.

Refs: #736
The pure-Nix image (Nix-but-not-NixOS) shipped neither the FHS dynamic
loader /lib64/ld-linux-x86-64.so.2 that every manylinux x86_64 wheel
hardcodes as its PT_INTERP, nor the Nix C++/compression runtime on the
loader path. Runtime-installed PyPI binaries therefore broke: standalone
tools (PyPI-pinned pre-commit ruff/typos) with "cannot execute: required
file not found", and C extensions dlopened by the baked CPython (numpy,
scipy, pre-commit pymarkdown's pyjson5) with "ImportError: libstdc++.so.6".

Symlink the Nix glibc loader to /lib64/ld-linux-x86-64.so.2 in the
bootstrap layer (newer glibc runs old-glibc wheels via backward
compatibility) and bake LD_LIBRARY_PATH with stdenv.cc.cc.lib (libstdc++
/libgcc_s) + zlib (libz). The loader symlink fixes standalone wheel
executables; LD_LIBRARY_PATH fixes the C-extension .so files dlopened by
the store CPython, which never traverse /lib64. This is the image-scope
analogue of the dev-shell #698 fix, ungated: an all-Nix container has no
foreign FHS host binaries to pollute, so the /etc/NIXOS ABI gate from
#698/#703 never applies.

Refs: #736
@c-vigo
c-vigo merged commit e934e0d into feature/625-nix-claude-migration Jun 29, 2026
10 checks passed
@c-vigo
c-vigo deleted the bugfix/736-manylinux-loader branch June 29, 2026 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant