How to set nix-shell C/C++ header search paths

Hi, I am trying to get a development shell with some packages from the nixpkgs and one I have pulled from github. after disabling the sandbox, I was able to get a development shell with the github package build. Assuming (maybe wrongly) that the headers provided by this package will be available in the nix develop shell path I try to compile a simple cpp program. But gcc says the header is not found. I am not sure which other path to set for nix develop shell to pickup these headers which do exist in the nix store. The paths are included as the buildInputs of the mkShell function, but still no joy.

cpp program below

#include <uhal/uhal.hpp>

int main() {return 0;}

flake.nix used below

{
  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

  outputs = { self, nixpkgs }:
    let
      pkgs = import nixpkgs { system = "x86_64-linux"; };
      uhal = pkgs.stdenv.mkDerivation {
        name = "build-uhal";
        src = builtins.fetchGit { url = "https://github.com/joealsubash/ipbus-software.git";
                                  ref = "jsubash/nix";
                                  rev = "cd1947655f24c7bd73727471e854bbbdd4240bf4"; };
        dontConfigure = true;                                                                                                                                                                                                                                                                                                                                                                  
        installPhase = "mkdir -p $out/opt/cactus/; mkdir -p $out/local/include; make install prefix=$out/opt/cactus includedir=$out/local/include";
        nativeBuildInputs = with pkgs; [
          cacert boost pugixml python311Packages.pybind11 erlang rebar git
        ];
        buildInputs = with pkgs; [
          cacert boost pugixml python311Packages.pybind11 erlang rebar git
        ];
      };
    in
      {
        devShells.x86_64-linux.default = pkgs.mkShell {
          packages = [
            pkgs.python311
            pkgs.boost
            pkgs.git
            pkgs.cmake
            "${uhal}/local/include/"                                                                                                                                                                                           
          ];
	};
        buildInputs = ["${uhal}/local/include/"];    
        nativeBuildInputs = ["${uhal}/local/include/"];                                                                                                                                                               
      };
}

Thanks.

In your dev shell, you want uhal instead of "${uhal}/local/include/". Assuming your uhal derivation is good, and puts files in the right place, the header files will be added to various nix specific env variables that the compiler wrappers reads.

Hi daniel,
Could you elaborate what you mean by ‘derivation is good’. Nix does manage to build it fine if that is what you mean. Any how, tried your suggestion but no joy. In the end added a shellHook which adds the paths manually to NIX_CFLAGS_COMPILE and CMAKE_INCLUDE_PATH, this worked. Probably not the most elegant solution but have tried many things which don’t work. Below is the updated flake.nix

{

  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
  outputs = { self, nixpkgs }:
    let
      pkgs = import nixpkgs { system = "x86_64-linux"; };
      uhal = pkgs.stdenv.mkDerivation {
        name = "uhal";
        src = builtins.fetchGit { url = "https://github.com/joealsubash/ipbus-software.git";
                                  ref = "jsubash/nix";
                                  rev = "cd1947655f24c7bd73727471e854bbbdd4240bf4"; };
        dontConfigure = true;
        installPhase = ''
        mkdir -p $out/opt/cactus/
        mkdir -p $out/local/include
        make install prefix=$out/opt/cactus includedir=$out/local/include
        '';
        nativeBuildInputs = with pkgs; [
          cacert boost pugixml python311Packages.pybind11 erlang rebar git
        ];
        buildInputs = with pkgs; [
          cacert boost pugixml python311Packages.pybind11 erlang rebar git
        ];
      };
    in
      {
        devShells.x86_64-linux.default = pkgs.mkShell {
          packages = [
            pkgs.python311
            pkgs.boost
            pkgs.git
            pkgs.cmake
          ];
          shellHook = ''
          export NIX_CFLAGS_COMPILE="-isystem ${uhal}/local/include/"$NIX_CFLAGS_COMPILE
          export CMAKE_INCLUDE_PATH="${uhal}/local/include/":$CMAKE_INCLUDE_PATH
          '';
        };
      };
}