Helping the wrapped cpp find things like sys/time.h

Hello. I am trying to resurrect a haskell package, haskell-xkbcommon.

I need Haskell bindings to some keysym types, in order to allow us to continue making progress on Haskell bindings to wlroots for making a Wayland compositor in Haskell.

This package I’m trying to resurrect, haskell-xkbcommon, is very old and out of date. I’m trying to get it to build again. It does some Template Haskell stuff that looks at C headers like <linux/types.h>, or <sys/time.h>. It uses the c pre-processor to expand an #include statement, then I assume it auto-generates some Haskell-side data types that represent the C structs that it found.

Thankfully, this code is in the IO monad so I can do some print debugging, and for some reason the code can find linux/input.h alright, but then when that file (linux/input.h) includes some other things, I get warnings about the files not being found. This then leads to a non-exhaustive pattern matching error, and the Haskell package’s build fails.

Now, what I don’t get is that I can do something like
ls /nix/store/mrgib0s2ayr81xv1q84xsjg8ijybalq3-glibc-2.38-27-dev/include/linux | rg time and the file looks like it exists. Now, it’s probably not being made available to the derivation for some reason. Usually, I add things to buildInputs, so that they can be found by a compiler in the package that I’m working on. But, I have no idea what the tree of #includes looks like, so I don’t think I could specify them one-by-one.

Here’s my flake (I love Flakes btw super excited)

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/23.11";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = nixpkgs.legacyPackages.${system};
        c_dependencies = [
          pkgs.libxkbcommon
        ];
      in {
        devShells.default = pkgs.mkShell {
          buildInputs = [
            pkgs.haskellPackages.cabal-install
            pkgs.haskellPackages.ghc
            pkgs.haskellPackages.haskell-language-server
          ] ++ c_dependencies;
        };
      }
    );
}

I think that pkgs.mkShell includes the stdenv, so a lot of the ‘normal’ tools for building C applications are typically available.

Is there any way that I can help the c preprocessor find these included files?

My repo is here GitHub - MattBrooks95/haskell-xkbcommon at get-it-to-build,

and the strange compile-time Haskell code that is using the c preprocessor to look up some file locations is in the file src/Text/XkbCommon/ParseDefines.hs, in the function genKeycodes.