diff --git a/doc/builders/packages/linux.section.md b/doc/builders/packages/linux.section.md index b64da85791a0d95..151f4820d857520 100644 --- a/doc/builders/packages/linux.section.md +++ b/doc/builders/packages/linux.section.md @@ -39,3 +39,20 @@ How to add a new (major) version of the Linux kernel to Nixpkgs: 4. Test building the kernel: `nix-build -A linuxKernel.kernels.kernel_2_6_22`. If it compiles, ship it! For extra credit, try booting NixOS with it. 5. It may be that the new kernel requires updating the external kernel modules and kernel-dependent packages listed in the `linuxPackagesFor` function in `linux-kernels.nix` (such as the NVIDIA drivers, AUFS, etc.). If the updated packages aren’t backwards compatible with older kernels, you may need to keep the older versions around. + +## Manual kernel configs {#sec-manual-kernel-configs} + +Sometimes it may not be desirable to use the kernels already packaged in Nixpkgs, especially if most of the default configuration has to be altered or disabled to achieve a kernel as expected by the target use case. An example of this is building a kernel for use in a VM or micro VM. Nixpkgs provides the `linuxManualConfig` function for these cases: it requires the caller to pass the kernel sources and a config file, allowing one to build their own kernel with specific tuning. + +An example usage of `linuxManualConfig`: + +```nix +{ pkgs, ... }: { + version = "X.Y.Z"; + src = pkgs.fetchurl { ... }; + configfile = ./path_to_config_file; + linux = pkgs.linuxManualConfig { inherit version src configfile; }; +} +``` + +Additional properties can be used with `linuxManualConfig` for further customisation. Readers who need more than the barebones example above should read [`pkgs/os-specific/linux/kernel/manual-config.nix`](https://github.com/NixOS/nixpkgs/blob/master/pkgs/os-specific/linux/kernel/manual-config.nix).