How to boot custom built kernel

Hi,

How can I get NixOS to boot a built kernel in a specified kernel source tree directory, for example /home/rah/my-modified-kernel/? I’ve searched the web, the NixOS wiki and these forums for information on how to do this, and asked on Matrix but to no avail.

Thanks,

rah

See this section of manual: Building a custom kernel. Wiki shows an example: Boot a kernel from a custom source, and use pkgs.fetchTarball(*.tar.gz) or builtin.path to fetch a local file.

src = pkgs.fetchTarball {
  name = "CUSTOMIZED_KERNEL";
  path = ./linux-kernel.tar.gz;
};

Please link to wiki.nixos.org instead, that other wiki is dead :slight_smile:

Namely Booting …

I’ve already seen these pages. The linked manual page describes building a kernel, presumably from nixpkgs, with a custom config. It’s not about installing and booting a kernel from a local kernel source tree.

This is about building a kernel from a tarball, not booting a kernel from a local source tree.

Set src to your local path, then.

To be clear, you mean a string containing the path of the directory?

No, I mean a path, not a string. A path does not have quotes around it.
https://nix.dev/manual/nix/2.24/language/syntax#path-literal

Still, this is about building the kernel, is it possible to install and boot an already-built kernel/modules/dtbs from a local directory? I don’t want to have to rebuild the entire kernel tree every time I make a change, which I understand is what Nix will do.

For posterity, from discussions on Matrix, the answer to this is “no”.