RustPackage: stuck on missing header `stdio.h`

Trying to package quackosm along its many dependencies. One of which is geoarrow-rs, declared as follow:

{
  lib,
  rustPlatform,
  fetchFromGitHub,
  libclang,
  gdal
}:
rustPlatform.buildRustPackage rec {
  pname = "geoarrow-rs";
  version = "0.2.0";

  src = fetchFromGitHub {
    owner = "geoarrow";
    repo = "geoarrow-rs";
    rev = "refs/tags/rust-v${version}";
    hash = "sha256-trOVsQKFz0/YyggpUJ63YADAOu/77eFcVtv0w2A88H8=";
  };

  # required for gdal-sys
  env = {
    LIBCLANG_PATH = "${lib.getLib libclang}/lib";
    GDAL_INCLUDE_DIR = "${lib.getDev gdal}/include";
  };

  cargoHash = "sha256-2U2WERqZp6moW1SBo7axaA0IThFuLT+PL5W0d1se0Jc=";

  meta = {
    description = "GeoArrow in Rust";
    homepage = "geoarrow.org/geoarrow-rs";
    license = with lib.licenses; [ mit asl20 ];
    maintainers = with lib.maintainers; [ sigmanificient ];
    platforms = lib.platforms.unix;
  };
}

However when building this derivation, i get the following error after quite a while of compilation:

   ...
   Compiling clap v4.5.3
   Compiling plotters v0.3.5
error: failed to run custom build command for `gdal-sys v0.9.1`

Caused by:
  process didn't exit successfully: `/build/source/target/release/build/gdal-sys-d45ae1c3aafd30bd/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=GDAL_STATIC
  cargo:rerun-if-env-changed=GDAL_DYNAMIC
  cargo:rerun-if-env-changed=GDAL_INCLUDE_DIR
  cargo:rerun-if-env-changed=GDAL_LIB_DIR
  cargo:rerun-if-env-changed=GDAL_HOME
  cargo:rerun-if-env-changed=GDAL_VERSION
  cargo:rerun-if-env-changed=GDAL_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

  --- stderr
  /nix/store/lzgpr5c01gwjlslhxklfgc98h8syjyal-gdal-3.9.1/include/cpl_port.h:119:10: fatal error: 'stdio.h' file not found
  thread 'main' panicked at /build/geoarrow-rs-0.2.0-vendor.tar.gz/gdal-sys/build.rs:37:10:
  Unable to generate bindings: ClangDiagnostic("/nix/store/lzgpr5c01gwjlslhxklfgc98h8syjyal-gdal-3.9.1/include/cpl_port.h:119:10: fatal error: 'stdio.h' file not found\n")
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

I am really lost on what is happening, and have no clue how to fix this. I hope someone could help me making this derivation build properly

I tried with nix-init, then added gdal to buildInputs.
That does in fact seem to build, but it also produces an empty $out oddly enough.

mind you share the derivation code?

Like I said, those two steps were all I did, you can run the same command and get the same.

{ lib
, rustPlatform
, fetchFromGitHub
, pkg-config
, openssl
, sqlite
, zstd
, stdenv
, gdal
, darwin
}:

rustPlatform.buildRustPackage rec {
  pname = "geoarrow-rs";
  version = "0.2.0";

  src = fetchFromGitHub {
    owner = "geoarrow";
    repo = "geoarrow-rs";
    rev = "rust-v${version}";
    hash = "sha256-2dWf5T89gU3n9ykWedAoQ0rPtmS/GhLEvXFfBIZStkU=";
    fetchSubmodules = true;
  };

  cargoHash = "sha256-2U2WERqZp6moW1SBo7axaA0IThFuLT+PL5W0d1se0Jc=";

  nativeBuildInputs = [
    pkg-config
    rustPlatform.bindgenHook
  ];

  buildInputs = [
    gdal
    openssl
    sqlite
    zstd
  ] ++ lib.optionals stdenv.isDarwin [
    darwin.apple_sdk.frameworks.CoreFoundation
    darwin.apple_sdk.frameworks.Security
    darwin.apple_sdk.frameworks.SystemConfiguration
  ];

  env = {
    ZSTD_SYS_USE_PKG_CONFIG = true;
  };

  meta = {
    description = "GeoArrow in Rust, Python, and JavaScript (WebAssembly) with vectorized geometry operations";
    homepage = "https://github.com/geoarrow/geoarrow-rs";
    changelog = "https://github.com/geoarrow/geoarrow-rs/blob/${src.rev}/CHANGELOG.md";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ ];
    mainProgram = "geoarrow-rs";
  };
}

Well i am unfamiliar with nix-init :sweat_smile:

You can try it. It prompts you exactly with what info it needs.