How to get a shell and development environment for a nixpkgs package?

I’m trying to cross-compile tree-sitter from x86_64 to aarch64 and the build is failing with

build logs

Last 25 log lines:

cargo:rerun-if-env-changed=CARGO_FEATURE_DUMP_SHAPES
cargo:rerun-if-env-changed=CARGO_FEATURE_DUMP_MODULE_RESOLVE
cargo:rerun-if-env-changed=CARGO_FEATURE_DUMP_PROMISE
cargo:rerun-if-env-changed=CARGO_FEATURE_DUMP_READ_OBJECT
cargo:rerun-if-env-changed=CARGO_FEATURE_DISABLE_ASSERTIONS
cargo:rerun-if-env-changed=CARGO_CFG_SANITIZE

— stderr
clang version 21.1.8
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir:
#include “…” search starts here:
#include <…> search starts here:
/nix/store/972s1xyrzy3pg1b91ca9nfksdcrjiv67-aarch64-unknown-linux-gnu-clang-wrapper-21.1.8/resource-root/include
/nix/store/pzldc0wip5mkwswn4ry3nfph0mvwzslw-glibc-aarch64-unknown-linux-gnu-2.42-61-dev/include
End of search list.
/nix/store/pzldc0wip5mkwswn4ry3nfph0mvwzslw-glibc-aarch64-unknown-linux-gnu-2.42-61-dev/include/bits/math-vector.h:182:9: error: unknown type name ‘__SVFloat32_t’
/nix/store/pzldc0wip5mkwswn4ry3nfph0mvwzslw-glibc-aarch64-unknown-linux-gnu-2.42-61-dev/include/bits/math-vector.h:183:9: error: unknown type name ‘__SVFloat64_t’
/nix/store/pzldc0wip5mkwswn4ry3nfph0mvwzslw-glibc-aarch64-unknown-linux-gnu-2.42-61-dev/include/bits/math-vector.h:184:9: error: unknown type name ‘__SVBool_t’

thread ‘main’ (3944) panicked at /build/tree-sitter-0.26.8-vendor/source-registry-0/rquickjs-sys-0.10.0/build.rs:352:39:
Unable to generate bindings: ClangDiagnostic(“/nix/store/pzldc0wip5mkwswn4ry3nfph0mvwzslw-glibc-aarch64-unknown-linux-gnu-2.42-61-dev/include/bits/math-vector.h:182:9: error: unknown type name ‘__SVFloat32_t’\n/nix/store/pzldc0wip5mkwswn4ry3nfph0mvwzslw-glibc-aarch64-unknown-linux-gnu-2.42-61-dev/include/bits/math-vector.h:183:9: error: unknown type name ‘__SVFloat64_t’\n/nix/store/pzldc0wip5mkwswn4ry3nfph0mvwzslw-glibc-aarch64-unknown-linux-gnu-2.42-61-dev/include/bits/math-vector.h:184:9: error: unknown type name ‘__SVBool_t’\n”)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish…

I want to debug the build, but I’m unsure how to build a package from nixpkgs in a local environment so I can inspect what is going on. Could anyone provide some pointers? I’m sure this is a common task that people want to do but I can’t find docs for it anywhere after about 1h of searching.

EDIT: It looks like the issue is that the build is trying to use SVE instruction set on ARM where it doesn’t exist. But I’m happy to figure that out myself if I can get a dev env.

EDIT 2: SVE is an ARM instruction set so IDK what’s happening, but again I just want to know how to get set up for investigating.

Consider changing the title of this topic from “How to fix bug in nixpkgs pkg” to something a bit more descriptive.

As I understand it, you are asking how to use nix-shell or nix develop to debug a package within nixpkgs (tree-sitter, in this case) with the complication that you are cross compiling.

I’m not really familiar at all with cross compiling, and I don’t know the nix3-style commands (nix develop)

Some googling and experimentation leads me to this:

mkdir tree-sitter-build
cd tree-sitter-build
nix-shell '<nixpkgs>' -A pkgsCross.aarch64-multiplatform.tree-sitter

Then within that shell:

definePhases
echo $phases
# prints: unpackPhase patchPhase updateAutotoolsGnuConfigScriptsPhase updateAutotoolsGnuConfigScriptsPhase configurePhase buildPhase checkPhase installPhase fixupPhase installCheckPhase distPhase
runPhase unpackPhase
runPhase patchPhase
runPhase updateAutotoolsGnuConfigScriptsPhase
runPhase updateAutotoolsGnuConfigScriptsPhase
runPhase configurePhase
runPhase buildPhase

From an x86_64-linux system, this fails for me at rquickjs-sys as well, so hopefully it helps you figure out what’s going on.

1 Like