Missing bindgenHook from rustPlatform while using in flake?

Hello there!

I’ve recently started trying to build a Rust project while on NixOS. The problem I’m having is that one of the dependencies I am wanting to use requires bindgen.

Since flakes seems to be all-the-rage lately, I’ve been using rust-overlay in my flake, and from what I can see in the manual I should be able to use rustPlatform.bindgenHook in order to overcome clang not being able to find the appropriate libraries/headers for the dependencies I am wanting to use, my flake is as follows:

  description = "Test Project";

  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.11";
  inputs.flake-utils.url = "github:numtide/flake-utils";
  inputs.rust-overlay.url = "github:oxalica/rust-overlay";
  outputs = { self, nixpkgs, flake-utils, rust-overlay, ... }:
    flake-utils.lib.eachDefaultSystem (system:
        overlays = [ (import rust-overlay) ];
        pkgs = import nixpkgs { inherit system overlays; };

        devShell = with pkgs; mkShell {
          buildInputs = [
          nativeBuildInputs = with pkgs; [
          LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";
          BINDGEN_EXTRA_CLANG_ARGS = "-isystem ${llvmPackages.libclang.lib}/lib/clang/${lib.getVersion clang}/include";



This leads me to the following error though, when attempting to run nix develop:

error: attribute 'bindgenHook' missing

       at /nix/store/7s4xwp7ksrcbwn1y1nnpmnmzcz7z62c4-source/flake.nix:23:13:

           22|             pkg-config
           23|             rustPlatform.bindgenHook
             |             ^
           24|           ];
(use '--show-trace' to show detailed location information)

Every where that I’ve searched, it seems bindgenHook should still exist, but my system is unable to find it. My knowledge of Nix and Flakes is still incredibly new, so I get the feeling that I’m just overlooking something simple.

If anyone has any ideas, I’d appreciate it!

That hook did not exist in 21.11. First release I was able to find it in was 22.05.

1 Like