Repository navigation
build(nix): expose libstdc++ in dev-shell so pymarkdown runs on NixOS - #700
Merged
c-vigo merged 3 commits intoJun 24, 2026
Merged
Conversation
The pymarkdown pre-commit hook runs from pre-commit's own manylinux-wheel Python env, whose dependency pyjson5 is a C extension linked against libstdc++.so.6. On a NixOS host that library is not on the loader path outside an FHS environment, so the hook failed with an ImportError and forced --no-verify. pymarkdown is not in nixpkgs, so the #697 "devTools + language:system" recipe does not apply. mkProjectShell now appends ${pkgs.stdenv.cc.cc.lib}/lib to LD_LIBRARY_PATH in the dev-shell (the same libstdc++ the Nix toolchain links, so no version clash), preserving any mkShell-injected value. Documented in docs/NIX.md. Refs: #698
…' into bugfix/698-pymarkdown-nixos # Conflicts: # CHANGELOG.md # assets/workspace/.devcontainer/CHANGELOG.md
This was referenced Jun 24, 2026
Closed
c-vigo
added a commit
that referenced
this pull request
Jun 29, 2026
Exposing the Nix store python3 on the dev-shell PATH (#729) made pre-commit build the pymarkdown hook env with the Nix interpreter, whose manylinux pyjson5 wheel cannot resolve libstdc++ on FHS hosts — the #700 LD_LIBRARY_PATH rescue is NixOS-gated (per #703), so it regressed #698 on the ubuntu CI runner. Revert to restore CI green; a host-safe re-implementation follows. Refs: #729
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The
pymarkdownpre-commit hook failed on a NixOS host withImportError: libstdc++.so.6: cannot open shared object file, forcing--no-verifyon every local commit.pymarkdownruns from pre-commit's ownmanylinux-wheel Python env (not the project venv); its dependency
pyjson5is aC extension linked against
libstdc++.so.6, which a NixOS host does not put onthe loader path outside an FHS environment. Unlike the standalone binaries in
sibling issue #697,
pymarkdownis not packaged in nixpkgs, so the "add todevTools+language: system" recipe does not apply.This PR makes the existing manylinux wheel resolve its C library by exposing the
Nix C++ runtime on the dev-shell loader path.
Type of Change
build-- Build system or dependency changesModifiers
!)Changes Made
flake.nix(mkProjectShell): append${pkgs.stdenv.cc.cc.lib}/libtoLD_LIBRARY_PATHvia the shell hook, preserving the value mkShell alreadyinjects (it auto-populates
LD_LIBRARY_PATHfrom some packages' propagatedlibs, e.g.
alsa-lib) and any host-set value. This is the same libstdc++the Nix toolchain itself links, so there is no version clash with the other
dev-shell binaries, and it generalises to any future C-extension Python hook.
tests/test_flake_devshell.py: two dev-shell parity tests (mirroring theexisting
dev_shell_env/BATS_LIB_PATHtests) assertingLD_LIBRARY_PATHcarries
libstdc++.so.6and that the C library loads under the dev-shellloader.
docs/NIX.md: documents the mechanism (and notesnix-ldas a non-enforceablefallback) under the pre-commit decisions section.
CHANGELOG.md(+ scaffolded mirror viasync_manifest):### Fixedentry.Approach chosen and alternatives rejected
LD_LIBRARY_PATH). Smallest, robust change;keeps the upstream
rev:pin; verified that pymarkdown runs and that the otherNix binaries (
just,nixfmt,jq,rg,git,nvim,lazygit,delta,bat,eza,taplo,shellcheck,claude) still run with it set. UsedLD_LIBRARY_PATHrather thanNIX_LD/NIX_LD_LIBRARY_PATH: the latter onlyhelps binaries launched through the NixOS
stub-ld, whereas the wheel's Cextension is
dlopen'd by an already-running Nix-store CPython that honoursLD_LIBRARY_PATHdirectly — the more general and host-independent lever.pymarkdownin the flake). Most hermetic, butpymarkdownis absent from nixpkgs, so it means abuildPythonApplicationfromthe PyPI sdist plus a version to maintain — more work than warranted to unblock
the hook, and the env fix is clean and robust. Left as a possible later
hermetic end-state.
nix-ldhost config). Per-contributorsystem config the repo cannot enforce; documented as a fallback only.
Changelog Entry
Fixed
pymarkdownpre-commit hook no longer fails on NixOS (pyjson5C extension missinglibstdc++) (#698)pymarkdownhook runs from pre-commit's own manylinux-wheel Python env, whose dependencypyjson5is a C extension linked againstlibstdc++.so.6; on a NixOS host that library is not on the loader path outside an FHS environment, so the hook aborted withImportError: libstdc++.so.6: cannot open shared object fileand forced--no-verify. Unlike the standalone binaries in #697,pymarkdownis not in nixpkgs, so the "add todevTools+language: system" recipe does not applymkProjectShellnow appends${pkgs.stdenv.cc.cc.lib}/libtoLD_LIBRARY_PATHin the dev-shell, so the wheel's C extension resolves the Nix C++ runtime. It is the samelibstdc++the Nix toolchain itself links, so the other dev-shell binaries keep working (no version clash); the existing mkShell-injectedLD_LIBRARY_PATHis appended to, not clobbered. Generalises to any future C-extension Python hook. Documented indocs/NIX.mdLD_LIBRARY_PATHcarrieslibstdc++.so.6and that the C library loads under the dev-shell loaderTesting
Manual Testing Details
All run on the NixOS host inside
nix develop:nix develop -c bash -c 'uv run pre-commit run pymarkdown --all-files'→
ImportError: libstdc++.so.6: cannot open shared object file.(
AssertionError: libstdc++.so.6 not found under LD_LIBRARY_PATH: /nix/store/...-alsa-lib.../lib), confirming mkShell already set a value thefix had to preserve.
nix develop -c bash -c 'uv run pre-commit run pymarkdown --all-files'→pymarkdown ... Passed(no manual env export, no--no-verify).uv run pytest tests/test_flake_devshell.py→8 passed.just,nixfmt,jq,rg,git,nvim,lazygit,delta,bat,eza,taplo,shellcheck,claudeallrun with
LD_LIBRARY_PATHset (ruffis absent on this branch only because itjoins
devToolsin [BUG] pre-commit: source binary hooks (ruff, ruff-format, typos) from the flake for NixOS compatibility #697 — not a regression here).nixfmt --check flake.nixclean;nix evalofdevShells/checksevaluate;nix build .#checks.x86_64-linux.formatsucceeds.
--no-verifyrationale: thepymarkdown/ruff/typospre-commit hookscannot run on this NixOS host pre-fix (the very bug being fixed, plus #697), so
the TDD commits used
git commit --no-verify. CI re-runs the full hook suiteunder
provision-via-flake. The new markdown was validated manually:pre-commit run pymarkdown --files CHANGELOG.md docs/NIX.md→ Passed.Checklist
docs/NIX.md)CHANGELOG.mdin the[Unreleased]section (and pasted the entry above)Additional Notes
Heads-up for the reviewer — likely merge conflicts with #697. Sibling issue
#697 (
bugfix/697-precommit-flake-hooks) also editsflake.nix,.pre-commit-config.yaml, andCHANGELOG.md:flake.nix: [BUG] pre-commit: source binary hooks (ruff, ruff-format, typos) from the flake for NixOS compatibility #697 addsruff/typostodevTools; this PR editsmkProjectShell. Different regions, but both touch the file.CHANGELOG.md: both add a### Fixedentry under## Unreleased(adjacentlines) → near-certain textual conflict; trivial to resolve (keep both).
.pre-commit-config.yaml: this PR does not touch it; [BUG] pre-commit: source binary hooks (ruff, ruff-format, typos) from the flake for NixOS compatibility #697 does. Noconflict from this side, but note the scaffolded
assets/workspace/.devcontainer/.pre-commit-config.yamlissync_manifest-mirrored.Both branches are based on
feature/625-nix-claude-migration.Refs: #698