Including a local custom library

Dear all,

trying to include a local library in a derivation. Found a thread here in the forum but the case looks slightly different, and cannot find a working example for my case.

i am packaging a “iio-oscilloscope” package but would use a “libiio” built locally from a certain git branch.

I tested callPackage inside the derivation, but then looks like library include path is not considered.
This is what i did till now, any help is very appreciated.

{
  pkgs ? import <nixpkgs> { }
}:

pkgs.stdenv.mkDerivation rec {
  pname = "iio-oscilloscope";
  version = "git";

  src = pkgs.fetchgit {
    url = "https://github.com/analogdevicesinc/iio-oscilloscope.git";
    rev = "fbd5aa5";
    sha256 = "sha256-JGj6yulwHnaHRf5YcLoB7CdrKzRKDvfBO4M6tcNFbqU=";
  };
  patches = [
    ./cmake.patch
    ./lidar.patch
  ];
  nativeBuildInputs = [
    pkgs.pkg-config
    pkgs.cmake
  ];
  cmakeFlags = [
    "-DCMAKE_VERBOSE_MAKEFILE=on"
    "-DCMAKE_SKIP_RPATH=on"
    "-Wno-error=maybe-uninitialized"
    "-Wno-error=uninitialized"
    "-Wno-error=restrict"
  ];
  buildInputs = with pkgs; [
    glib
    gtk3
    gtkdatabox
    fftw
    libxml2
    libad9361
    curl
    matio
    jansson
    libiio
    #(callPackage ../libiio-1.00 { })
  ];
}