How to fix some C/C++ programs build by skbuild for NixOS?

Comes from After pre-commit run -a, some tools will be installed to a path like ~/.cache/pre-commit/repo644wkxa5/py_env-python3.10/lib/python3.10/site-packages/clang_format/data/bin/clang-format. Which will not be patchelfed so they cannot work. How to fix it?

The best solution is building these pograms from source code, not download compiled binary files.

1 Like

Please do not report Nix-specific issues to project without a clear action plan. Nix is sufficient different from mainstream that asking projects to support it tends to create a bad blood.

These programs typically use pre-built binaries because requiring every user to build stuff (especially with huge projects like LLVM) would be inconvenient. When the binaries will work for most Linux, using them is ugly but pragmatic solution.

With Nix, the cleanest solution would probably be using Nix specific tooling like poetry2nix to install the package and using overlays to patch the package build system to use CLang from Nixpkgs rather than building it from scratch. Here the project could help by adding CMake options for passing the path to clang-format and skipping the LLVM build when provided.

If you want to use it through non-Nix Python tooling directly from PyPI, the best the project can do is using clang-format from PATH if it is available (potentially controlled by an environment variable like CLANG_FORMAT_WHEEL_USE_FROM_SYSTEM). But that you will still be downloading extra binaries you will not use.

Hosted by Flying Circus.