From c7dfeb21e58a1b79ec2f60f0955a4af37a749267 Mon Sep 17 00:00:00 2001 From: AlexBSoD <13933267+AlexBSoD@users.noreply.github.com> Date: Wed, 29 Jul 2026 14:39:55 +0300 Subject: [PATCH] fix(nix): provide libclang in the dev shell MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- flake.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/flake.nix b/flake.nix index 577caad6ca..937769bf1b 100644 --- a/flake.nix +++ b/flake.nix @@ -170,6 +170,10 @@ env = { CARGO_NET_GIT_FETCH_WITH_CLI = "true"; + # nrf-mpsl-sys and nrf-sdc-sys run bindgen, which dlopens libclang + # at build-script time. Without this every nRF firmware build fails + # with "Unable to find libclang". + LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; RUST_MIN_STACK = "67108864"; RUST_SRC_PATH = "${stableToolchain}/lib/rustlib/src/rust/library"; };