1# How to add a new (major) version of the Linux kernel to Nixpkgs:
2
31. Copy the old Nix expression (e.g., `linux-2.6.21.nix`) to the new one (e.g., `linux-2.6.22.nix`) and update it.
4
52. Add the new kernel to the `kernels` attribute set in [`linux-kernels.nix`](../../../top-level/linux-kernels.nix) (e.g., create an attribute `kernel_2_6_22`).
6
73. Update the kernel configuration:
8
9 1. While in the Nixpkgs repository, enter the development shell for that kernel:
10
11 ```console
12 $ nix-shell -A linuxKernel.kernels.linux_2_6_22
13 ```
14
15 2. Unpack the kernel:
16
17 ```console
18 [nix-shell]$ pushd $(mktemp -d)
19 [nix-shell]$ unpackPhase
20 ```
21
22 3. For each supported platform (`i686`, `x86_64`, `uml`) do the following:
23
24 1. Make a copy from the old config (e.g., `config-2.6.21-i686-smp`) to the new one (e.g., `config-2.6.22-i686-smp`).
25
26 2. Copy the config file for this platform (e.g., `config-2.6.22-i686-smp`) to `.config` in the unpacked kernel source tree.
27
28 3. Run `make oldconfig ARCH={i386,x86_64,um}` and answer all questions. (For the uml configuration, also add `SHELL=bash`.) Make sure to keep the configuration consistent between platforms (i.e., don’t enable some feature on `i686` and disable it on `x86_64`).
29
30 4. If needed, you can also run `make menuconfig`:
31
32 ```ShellSession
33 $ nix-shell -p ncurses pkg-config
34 $ make menuconfig ARCH=arch
35 ```
36
37 5. Copy `.config` over the new config file (e.g., `config-2.6.22-i686-smp`).
38
394. Test building the kernel:
40
41```ShellSession
42nix-build -A linuxKernel.kernels.kernel_2_6_22
43```
44
45If it compiles, ship it! For extra credit, try booting NixOS with it.
46
475. 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.