Skip to content

[BUG] pre-commit: make the pymarkdown hook (pyjson5 C-extension / libstdc++) run on NixOS #698

Closed

Description

@c-vigo

Description

Follow-up to #697. The pymarkdown pre-commit hook also fails on a NixOS host,
but it is a different failure class than the standalone Rust binaries: it is a
pure-Python tool whose dependency pyjson5 ships a C extension that needs
libstdc++.so.6 on the loader path, which a NixOS host does not provide outside
an FHS/nix develop environment.

This is split from #697 because the standalone binaries (ruff, typos) have
drop-in nixpkgs packages, whereas pymarkdown does not — so it needs its own
investigation and decision.

Evidence

$ uv run pre-commit run pymarkdown --all-files
  File ".../pyjson5/__init__.py", line 1, in <module>
    from .pyjson5 import *
ImportError: libstdc++.so.6: cannot open shared object file: No such file or directory

pymarkdown is not packaged in nixpkgs (pymarkdown /
python3Packages.pymarkdownlnt both absent), so the simple "add to devTools +
language: system" recipe from #697 does not apply directly.

Options to investigate

  1. Provide libstdc++ to the loader in the dev-shell — add
    pkgs.stdenv.cc.cc.lib and set LD_LIBRARY_PATH (or NIX_LD_LIBRARY_PATH)
    in mkProjectShell so the existing manylinux pyjson5 wheel resolves its
    C library. Smallest change; keeps the upstream rev: pin; mildly impure.
  2. Package pymarkdown in the flake — buildPythonApplication from the
    PyPI sdist with pyjson5 taken from nixpkgs (python3Packages.pyjson5,
    built against the Nix libstdc++), exposed as a pymarkdown binary, then a
    language: system hook. Most hermetic / SSoT-aligned; most work; adds a
    version to maintain.
  3. nix-ld (host-level) — programs.nix-ld.enable with
    libraries = [ pkgs.stdenv.cc.cc ] makes the wheel work unchanged. Not
    repo-enforceable (per-contributor system config); document as fallback. See
    the alternative discussion in [BUG] pre-commit: source binary hooks (ruff, ruff-format, typos) from the flake for NixOS compatibility #697.
  4. Drop/replace pymarkdown — only if markdown linting can move to a
    Nix-friendly tool without losing the .pymarkdown config behaviour
    (likely undesirable; listed for completeness).

Leaning: Option 1 as the pragmatic unblock (and it generalises to any future
C-extension Python hook), with Option 2 as the hermetic end-state if we want
pymarkdown fully off upstream wheels. Confirm during execution.

Acceptance criteria

  • pre-commit run pymarkdown --all-files passes in the dev-shell on a NixOS
    host (no --no-verify)
  • Chosen mechanism documented in docs/NIX.md
  • CI project-checks job stays green
  • If the dev-shell gains libstdc++/LD_LIBRARY_PATH, a dev-shell parity
    test asserts it (mirrors the existing UV_PYTHON/BATS_LIB_PATH tests)

Relationship

Refs: #625

Activity

  1. added
    bug
    priority:medium
    area:workflow
    semver:patch
    on Jun 24, 2026
  2. self-assigned this
    on Jun 24, 2026
  3. c-vigo commented on Jun 24, 2026

    @c-vigo
    ContributorAuthor

    Fixed and merged into the epic branch feature/625-nix-claude-migration via #700 (merge 77a8f4a). Verified in the dev-shell: pre-commit run pymarkdown passes (the pyjson5 C extension resolves libstdc++ via the dev-shell LD_LIBRARY_PATH). Left open to match the epic's sub-issue convention (cf. #695).

  4. c-vigo commented on Jun 30, 2026

    @c-vigo
    ContributorAuthor

    Resolved by #700 (c59f932) on the Nix-migration branch (epic #625, PR #670). Closing as part of post-merge backlog hygiene (#677).

  5. added a commit that references this issue on Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:workflowbugpriority:mediumsemver:patch

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions