Building one C++ flake that depends on another

I’m trying to build one C++ based flake (“hello”) that depends on another (“TVM”) (both local to my file system). The parent flake (TVM) installs several sub directories of header files from several locations in it’s directory tree in $out/include/{tvm,dlpack} when built. But when building the dependent flake, nix build . complains that a header file can’t be found:

       > building
       > In file included from ./
       > /nix/store/wd1dbrznwz1pqkmz8zrwkil0n70yxgl6-source/include/tvm/runtime/c_runtime_api.h:72:10: fatal error: 'dlpack/dlpack.h' file not found
       > #include <dlpack/dlpack.h>
       >          ^~~~~~~~~~~~~~~~~
       > 1 error generated.
       For full logs, run 'nix log /nix/store/bw9zga4mq6qxga66hpmr1al37rfczy53-hello.drv'.

And when looking into that /nix/store/<nar>-source directory, it looks like that is a ‘raw’ (unbuilt) directory tree of TVM (which doesn’t have all the right paths in ./include instead of a built version of that flake (which I’ve confirmed has the right includes in $out/include/{dlpack,tvm}).


  1. Why is Nix trying to build the child flake using include paths into a raw, /nix/store/<nar>-source tree of an input flake, rather than the built resulting flake output like /nix/store/<nar>-tvm?
  2. Is there any way to tell it to use the built flake instead for include paths?
  3. I’m also even having trouble figuring out what a /nix/store/<nar>-source path even is? Is this type of source output/intermediary called something specific so I can research it further?

I’ve uploaded the child (libgen) and parent (TVM) flake.nix here with the file. And for full context, here’s the TVM flake in it’s full repository.

Any help much appreciated! Had a devil of a time googling breadcrumbs on this one.

You are using the flake as buildInput, not it’s outputs.

My assumption was that adding a flake as an input and buildInput to another flake would then mean one is referencing it’s output? Just like I’m doing with the other nixpkgs.<foo> references?

How then do you reference a flakes outputs?

As a flake can have many outputs, you have to specify them:

x.packages.${system}.hello, or whatever the actual path of the required output is.

Fascinating! So a buildInputs entry of the entire flake tvm equates to the source package, whereas tvm.packages.${system}.tvm references the output.

Ahh, and now I also see why the line pkgs = nixpkgs.legacyPackages.${system}; is there. Thanks!

No, it relates to the flake! It is not related to the package at all.

It is just coincidental that the flake lives in the same repository as the packages source.

Ahh, interesting, thank you again!