Linux headers not found, don't know how to install

I am trying to compile a C file that uses the linux headers, but I can’t seem to understand how to install them.

Here is the output:

../headers/vm.h:1:10: fatal error: 'linux/version.h' file not found
#include <linux/version.h>
1 error generated.
make: *** [Makefile:16: build] Error 1

And here’s the system info:

Linux nixos 6.1.38 #1-NixOS SMP PREEMPT_DYNAMIC Wed Jul  5 17:27:38 UTC 2023 x86_64 GNU/Linux

Any help will be greatly appreciated! :>

1 Like

You enter a nix-shell with the package which includes that header. Locate the package using nix-locate from nix-index.

If you’re building a project that is already packaged in Nixpkgs, you can also use nix-shell '<nixpkgs>' -A yourPackageHere to get a shell with all required dependencies.

Perhaps the OP has found an answer but I’d like to post a solution for those who came later.

with the package linuxHeaders, the headers are at "${linuxHeaders}/include". You may add the path to CPATH/C_INCLUDE_PATH/CFLAGS as you would manually do it with your compiler by cc -I"${linuxHeaders}/include}"