I want the linux headers for kernel version
5.15.107. The current linuxHeaders package is for 6.2. I’ve scanned the package and I don’t see a way to override the particular kernel version.
I want to build and experiment with kernel modules available here, GitHub - martinezjavier/ldd3: Linux Device Drivers 3 examples updated to work in recent kernels, and that requires older versions of the kernel and related headers.
linuxHeaders is for building userspace programs, where the API is supposed to avoid breaking changes. To build kernel modules, you need to use the full package for the kernel you want, e.g.
linux_5_15, because you need more than just the headers. There are lots of examples of out-of-tree kernel modules in Nixpkgs you should be able to take inspiration from.
That’s a great tip! I’ve found several kernel modules in
nixpkgs/pkgs/os-specific/linux by searching for the string
installTargets = [ "modules_install" ];.
Would there be kernel modules in
nixpkgs/nixos as well, and if so, how can I find them?
This question doesn’t make too much sense, because packages don’t live in nixpkgs/nixos. If you want to use an out-of-tree module on NixOS, you can put the package in the
boot.extraModulePackages option. There’s an example in the NixOS manual.