NixOS Rust-for-Linux
Assuming you mean Rust-for-Linux (in-tree kernel modules), the usual workflow is a dev shell for the build plus QEMU for testing, rather than booting the kernel on your NixOS machine.
1. Dev shell (shell.nix, channels-style):
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
nativeBuildInputs = with pkgs; [
gnumake flex bison bc pkg-config ncurses
llvmPackages.clang llvmPackages.lld llvmPackages.libclang
rustc cargo rust-bindgen rustfmt clippy rust-analyzer
openssl elfutils perl qemu busybox
];
RUST_LIB_SRC = "${pkgs.rustPlatform.rustLibSrc}";
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
hardeningDisable = [ "all" ];
}
hardeningDisable matters because Nix’s default hardening flags break kernel builds.
