This is how you build a test kernel with NixOS shenanigans:
podman pull nixos/nix
podman run -it --rm -v "$(pwd):/kekkonen:Z" nixos/nix bash
cd kekkonen
nix-build '<nixpkgs/nixos>' -A config.system.build.qcow2 -I nixos-config=./configuration.nix
I’m planning to use this for Rust Linux instead of tweaking my BuildRoot environment at least at first.
Here’s an example on how to enable a custom kernel, albeit not yet with anything Rust. I just tested it with my in progress driver:
boot.kernelPackages = let
linux_tpmdd_pkg = { fetchgit, buildLinux, ... } @ args:
buildLinux (args // rec {
extraConfig = ''
64BIT y
ACPI y
CRYPTO y
IKHEADERS y
LOCKDEP y
MEMORY_FAILURE y
MODULES n
PROVE_LOCKING y
RETPOLINE y
TCG_TPM y
TCG_TIS y
TCG_CRB y
'';
ignoreConfigErrors = true;
kernelPatches = [];
src = pkgs.fetchgit {
url = "https://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd.git";
rev = "master";
sha256 = lib.fakeSha256;
};
version = "5.10";
} // (args.argsOverride or {}));
linux_tpmdd = pkgs.callPackage linux_tpmdd_pkg{};
in
pkgs.recurseIntoAttrs (pkgs.linuxPackagesFor linux_tpmdd);
EDIT: That did not play out so well but I then I looked at my old gists and recalled how this should be actually done: https://gist.github.com/jarkkojs/86bda141204e792122ef0c94b8b083b1. Has been three years since I bootstrapped a kernel tree in NixOS.