Skip to content

fix: add pkg-config to Nix devShell for libffi discovery on bare machines - #9

Merged
nomeata merged 2 commits into
masterfrom
copilot/fix-ci-runtime-discrepancy
Feb 21, 2026
Merged

nomeata merged 2 commits into
masterfrom
copilot/fix-ci-runtime-discrepancy

Conversation

Copilot AI commented Feb 21, 2026 •

Copy link
Copy Markdown
Contributor

On minimal self-hosted runners (bare Hetzner), the RPython/PyPy translation step for rpylean fails because pkg-config is absent from the system PATH — GitHub-hosted runners have it pre-installed, bare machines do not.

The PyPy RPython translator calls pkg-config libffi --libs-only-L at compile time to locate libffi. Without the binary:

ValueError: running 'pkg-config libffi --libs-only-L' failed:
[Errno 2] No such file or directory
and the default ['/usr/lib/libffi'] is not a valid directory

Changes

  • flake.nix: Add pkg-config to buildInputs. The already-present libffi.dev provides the libffi.pc file; Nix's mkDerivation devShell automatically populates PKG_CONFIG_PATH from buildInputs, so pkg-config can resolve libffi entirely from the Nix store.
Original prompt

Create a pull request to fix a CI/runtime discrepancy between GitHub-hosted runners and a self-hosted bare Hetzner machine for repository leanprover/lean-kernel-arena.

Context:

Goal:
Ensure that when running under the provided Nix shell/devShell (including in CI), the Python code reliably picks up the Nix-provided libffi (e.g., via correct environment variables, rpath, or Python package configuration), so behavior matches GitHub-hosted runners and self-hosted machines.

Requirements:

  1. Investigate where Python is trying to load libffi (likely via ctypes / cffi / ffi bindings) and why it succeeds on GitHub-hosted runners but fails on self-hosted.
  2. Update Nix configuration and/or runtime environment to ensure the dynamic loader can find libffi from the Nix store when running the Python entrypoints/tests.
    • Possible solutions include setting LD_LIBRARY_PATH, DYLD_LIBRARY_PATH (if relevant), NIX_LDFLAGS, LIBRARY_PATH, PKG_CONFIG_PATH, CFLAGS/LDFLAGS, CTYPESGEN, patching wrappers, or using makeWrapper/wrapProgram to inject needed env vars.
    • Prefer an approach that is robust and minimal, and doesn’t rely on system-wide packages.
  3. Add/adjust CI or a small regression test that exercises the Python code path that loads libffi, ensuring failure would be caught on machines without system libffi.
  4. Keep the solution Nix-centric: the nix shell should provide everything needed.

Deliverables:

  • A PR with changes to the relevant Nix files (e.g., flake.nix, shell.nix, default.nix, etc.) and/or Python startup code/wrappers so libffi is found.
  • Clear commit message(s) and a short PR description explaining the root cause and fix.

Notes:

  • Assume the self-hosted machine is a minimal Linux environment where only Nix-provided dependencies are available.
  • Ensure the solution works both for nix develop (or equivalent) and for CI workflows.

This pull request was created from Copilot chat.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

On the self-hosted bare Hetzner machine, the RPython/PyPy translation step
for the rpylean checker fails with:

  ValueError: running 'pkg-config libffi --libs-only-L' failed:
  [Errno 2] No such file or directory
  and the default ['/usr/lib/libffi'] is not a valid directory

The PyPy RPython translator uses `pkg-config libffi` to locate the libffi
library at build time. On GitHub-hosted runners, pkg-config is pre-installed
system-wide; on the bare self-hosted machine it is not.

The fix adds `pkg-config` to the devShell buildInputs. The existing
`libffi.dev` entry already provides the libffi.pc file, and Nix's
mkDerivation devShell automatically sets PKG_CONFIG_PATH to include it.
With pkg-config now in PATH, the RPython translator can successfully
locate libffi from the Nix store on any machine.

Co-authored-by: nomeata <[email protected]>
Copilot AI changed the title [WIP] Fix CI/runtime discrepancy on self-hosted machine for libffi fix: add pkg-config to Nix devShell for libffi discovery on bare machines Feb 21, 2026
Copilot AI requested a review from nomeata February 21, 2026 13:35
@nomeata
nomeata marked this pull request as ready for review February 21, 2026 14:35
@nomeata
nomeata merged commit 874bd67 into master Feb 21, 2026
4 checks passed
nomeata pushed a commit that referenced this pull request Nov 27, 2026
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.

2 participants