Last active
November 6, 2025 14:42
-
-
Save cablehead/4813334c753df556b1940137a3160ba7 to your computer and use it in GitHub Desktop.
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
| Analysis Complete | |
| I've reviewed the http-nu repository and found the key insights for fixing the Darwin build failure in nixpkgs. | |
| Root Cause | |
| The libproc v0.14.11 crate (a transitive dependency via nu-system → part of Nushell) uses bindgen to generate Rust bindings from C code. Bindgen requires libclang to compile, but the current nixpkgs package | |
| definition doesn't provide it for Darwin builds. | |
| How http-nu Successfully Builds on Darwin | |
| The project uses two approaches: | |
| 1. GitHub Actions CI (ci.yml:19): Runs directly on macos-latest runners where Xcode toolchain provides libclang automatically | |
| 2. Cross-compilation (for releases): Uses Dagger with joseluisq/rust-linux-darwin-builder Docker image, which includes: | |
| - OSXCross toolchain with libclang | |
| - A custom workaround script (scripts/cross-build-darwin.sh:20-45) that handles a specific libproc file copy issue | |
| The Fix for nixpkgs | |
| The modern nixpkgs solution is to use rustPlatform.bindgenHook, which automatically configures LIBCLANG_PATH and BINDGEN_EXTRA_CLANG_ARGS for bindgen. | |
| Required changes to pkgs/by-name/ht/http-nu/package.nix: | |
| 1. Add to function parameters: | |
| - stdenv | |
| - darwin | |
| 2. Add nativeBuildInputs: | |
| nativeBuildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ | |
| rustPlatform.bindgenHook | |
| ]; | |
| 3. Add buildInputs for Darwin frameworks: | |
| buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ | |
| darwin.apple_sdk.frameworks.IOKit | |
| darwin.apple_sdk.frameworks.SystemConfiguration | |
| ]; | |
| The bindgenHook will handle all the libclang path setup automatically, and the Darwin frameworks provide the system libraries that libproc needs to link against. | |
| This is the standard pattern used across nixpkgs for Rust packages that depend on crates using bindgen. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment