Hi everyone! I wanted to share a flake I made recently when I wanted to write linux kernel modules without fear of breaking my system.
What is it?
A flake for getting started with kernel module development. Clone the flake and immediately get started with developing and testing your kernel module. Builds a minimally configured linux kernel (only a few minutes to compile), an initrd, and a command for starting up a QEMU machine with your module included. (Plus you can use eBPF!).
Why?
Many getting started guides for module development, compiling the linux kernel, and setting up QEMU (in the context of kernel dev) are not very helpful for Nix users. This is because compiling the Linux kernel and creating initrds using Nix binaries has specialized Nix tools/functions.
I had to spend hours digging into these functions to get everything up and running. This is a huge investment if you just want to jump in and start writing some kernel modules. The flake let’s you focus on learning to write kernel modules without all the extra tooling (eg using The Linux Kernel Module Programming Guide).