With Rust coming maybe to Linux 5.20, I’m eager to have 0-day support in Nixpkgs. We are writing Linux kernel modules at work and package them with Nix. I would love to switch to Rust as soon as possible.
I managed to do a quick’n’dirty PoC here. You can build it with nix-build -A pkgs.linux_rust
.
I would appreciate, if someone with a better understanding of how to fit this neatly into the existing derivations, would lend a hand. At this point some basic advise on how everything should be structured would already be helpful.
What needs to happen is roughly this:
- Package a Linux kernel compatible version of bindgen (0.56)
- Make rustc, bindgen and the Rust source available at Linux config file and build time (but only for kernels with
CONFIG_RUST
enabled) - Find a way to disable incomaptible Linux config options (e.g.
DEBUG_INFO_BTF
).
I’ll also try to package the example out-of-tree module, because it could be a good template for anyone that needs to package other Rust kernel modules.
If someone wants to chat, I’m @js:ukvly.org in the #rust:nixos.org Matrix room.