fix(nix): provide libclang in the dev shell - #7
Open
AlexBSoD wants to merge 1 commit into
Open
Conversation
Building any nRF firmware from `nix develop` fails in the build script of
nrf-mpsl-sys:
Unable to find libclang: "couldn't find any valid shared libraries
matching: ['libclang.so', ...], set the `LIBCLANG_PATH` environment
variable to a path where one of these files can be found"
Both nrf-mpsl-sys and nrf-sdc-sys generate their bindings with bindgen, which
dlopens libclang at build time. The dev shell ships a full Rust toolchain and
the embedded tooling but never provided one, so every contributor had to dig a
clang out of the store and pass LIBCLANG_PATH by hand.
Point it at pkgs.llvmPackages.libclang. Verified by building keyboards/k04
central from a clean CARGO_TARGET_DIR inside `nix develop` with no manually
exported variables; nrf-mpsl-sys and nrf-sdc-sys both compile.
No BINDGEN_EXTRA_CLANG_ARGS is needed here — scripts/build_k04_matrix.sh still
derives its own when it wants ARM headers, and a plain cargo build does not.
AlexBSoD
force-pushed
the
fix/flake-libclang
branch
from
August 12, 2026 20:58
2de3431 to
e778907
Compare
Author
|
Rebased and green where it can be: the Build workflow passes, and the red This branch only touches |
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.
Problem
Building any nRF firmware from inside
nix developfails in thenrf-mpsl-sysbuild script:nrf-mpsl-sysandnrf-sdc-sysgenerate their bindings with bindgen, which dlopens libclang at build-script time. The dev shell ships the full Rust toolchain, the embedded targets,flip-link,probe-rs,cargo-binutils— but no libclang, so anyone building firmware has to find a clang in the store and exportLIBCLANG_PATHby hand every time.Fix
Set
LIBCLANG_PATHtopkgs.llvmPackages.libclangin the dev shell env.Testing
Built
keyboards/k04central from a cleanCARGO_TARGET_DIRinsidenix develop, with no manually exported variables —nrf-mpsl-sysandnrf-sdc-sysboth compile and the build finishes.alejandra --checkis clean.Note
No
BINDGEN_EXTRA_CLANG_ARGSis added: a plaincargo builddoesn't need it, andscripts/build_k04_matrix.shalready derives its own when it wants ARM headers.