Can't compile Cmake application with llhttp library

I have been trying to compile an application which requires the llhttp library, I’m currently using the following derivation file:

{
  stdenv,

  libuv,
  openssl,
  llhttp,
  zlib,
  cmake,
  pkg-config,

  fetchFromGitHub,
}:
stdenv.mkDerivation rec {
  version = "0.33.9";
  pname = "tlsuv";

  src = fetchFromGitHub {
    owner = "openziti";
    repo = "tlsuv";
    tag = "v${version}";
    hash = "sha256-um6aE0yK+lXfvaiKYugxavbXQRVm3mE+EeP6nuqYH8E=";
  };

  nativeBuildInputs = [
    cmake
    pkg-config
  ];

  buildInputs = [
    libuv
    openssl
    llhttp
    zlib
  ];
}

When building I get the following CMake error:

CMake Error in CMakeLists.txt:
  Imported target "llhttp::llhttp_static" includes non-existent path

    "/nix/store/fcfxn8y0fvdzkrcbfxr6a4fl5ixrr19y-llhttp-9.2.1/include"

  in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:

  * The path was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and references files it does not
  provide.

I checked the llhttp-9.2.1-dev nix package and found the cmake file. If I’m understanding this correctly, it seems to have an error:
/nix/store/[…]-llhttp-9.2.1-dev/lib/cmake/llhttp/llhttp-config.cmake
(Snippet for brevity)

# The installation prefix configured by this project.
set(_IMPORT_PREFIX "/nix/store/fcfxn8y0fvdzkrcbfxr6a4fl5ixrr19y-llhttp-9.2.1")

# Create imported target llhttp::llhttp_shared
add_library(llhttp::llhttp_shared SHARED IMPORTED)

set_target_properties(llhttp::llhttp_shared PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
)

# Create imported target llhttp::llhttp_static
add_library(llhttp::llhttp_static STATIC IMPORTED)

set_target_properties(llhttp::llhttp_static PROPERTIES
  # PS: this points the regular llhttp package output, which doesn't contain any headers. 
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
)

I’d greatly appreciate it, if someone more experienced with nix could tell me whether this is an bug in packaging, or if I’m understanding something incorrectly.

The packaging of llhttp in nixpkgs try to split outputs: nixpkgs/pkgs/by-name/ll/llhttp/package.nix at 06c3a28f6356830667387ca2e720140a06574106 · NixOS/nixpkgs · GitHub

But this does not work out of the box with this project, so this should either not be split, or be fixed.

Short term fast solution for you:

buildInputs = [
    libuv
    openssl
    (llhttp.overrideAttrs {outputs = ["out"];})
    zlib
  ];

I’ll open a PR to fix this in nixpkgs

for ref. : llhttp: don't split outputs by nim65s · Pull Request #398199 · NixOS/nixpkgs · GitHub

Thank you very much for your help!

If your problem is solved, please click on the “tick in a square” button to mark this topic as done :slight_smile: