Skip to content
Linux kernel module written in Zig
Makefile C Zig Nix
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
Makefile first commit Aug 11, 2019 improve description Aug 11, 2019
printk.h first commit Aug 11, 2019

Linux kernel module written in Zig

This is a proof-of-concept on how to integrate zig into Linux kernel modules.


This assumes that you kernel headers installed. In Debian based systems can be done using apt-get install linux-headers-$(uname -r).

$ make
$ sudo insmod ./zig.ko
$ sudo rmmod zig
$ dmesg | grep 'kernel!'
[41188.642871] Hello kernel!
[41190.975214] Goodbye kernel!

If your Linux distribution does not install kernel headers to /lib/modules/*/build, you can also set the KERNELDIR environment variable:

make KERNELDIR=/path/to/headers/build

On NixOS spawn a nix-shell from the project root:

nix-shell --command "make"

You might need to replace the Linux package in default.nix with the package matching your loaded kernel.

You can’t perform that action at this time.