diff --git a/flake.nix b/flake.nix index 35d15f4..3b14cd2 100644 --- a/flake.nix +++ b/flake.nix @@ -49,6 +49,8 @@ buildInputs = [ config.packages.nix ]; + # Workaround: the gcc in the devshell doesn't find libc headers + RUST_NIX_C_RAW_EXTRA_CFLAGS = "-I${pkgs.stdenv.cc.libc.dev}/include"; nativeBuildInputs = [ pkgs.rust-analyzer pkgs.nixpkgs-fmt diff --git a/rust/nix-c-raw/build.rs b/rust/nix-c-raw/build.rs index d8c6679..ae37b02 100644 --- a/rust/nix-c-raw/build.rs +++ b/rust/nix-c-raw/build.rs @@ -36,6 +36,13 @@ fn c_headers() -> Vec { { args.push(format!("-I{}", path.to_str().unwrap())); } + + if let Ok(cflags) = std::env::var("RUST_NIX_C_RAW_EXTRA_CFLAGS") { + for flag in cflags.split_whitespace() { + args.push(flag.to_string()); + } + } + // write to stderr for debugging eprintln!("c_headers: {:?}", args); args diff --git a/rust/nix-c-raw/include/nix-c-raw.h b/rust/nix-c-raw/include/nix-c-raw.h index 81883f6..129181e 100644 --- a/rust/nix-c-raw/include/nix-c-raw.h +++ b/rust/nix-c-raw/include/nix-c-raw.h @@ -1,3 +1,4 @@ #include #include #include +#include