# The \*correct\* way to override the latest kernel config

**URL:** https://discourse.nixos.org/t/the-correct-way-to-override-the-latest-kernel-config/533
**Category:** Help
**Created:** [July 17, 2018, 10:38pm UTC](https://discourse.nixos.org/t/the-correct-way-to-override-the-latest-kernel-config/533 "2018-07-17T22:38:53Z")
**Posts on this page:** 1
**Showing post:** 7

<div class="post-metadata">

### Author: ![aszlig](https://discourse.nixos.org/user_avatar/discourse.nixos.org/aszlig/32/78_2.png) [@aszlig](https://discourse.nixos.org/u/aszlig)
#### Post date: [July 30, 2018, 1:43pm UTC](https://discourse.nixos.org/t/the-correct-way-to-override-the-latest-kernel-config/533/7 "2018-07-30T13:43:30Z")

</div>

Ah, so now I’m getting what @layus was referring to 💡 (hopefully).

So let’s say you want to override the kernel in `linuxPackages_latest`, independent of NixOS.

Let’s look at how `linuxPackages_latest` is defined:

```nix
{
  # ...
  # Here is the composition of all the kernel packages for the given kernel:
  linuxPackagesFor = kernel: lib.makeExtensible ...;
  # linuxPackages_latest is just an alias for the latest kernel version.
  linuxPackages_latest = linuxPackages_4_17;
  # This composes the kernel packages for linux_4_17, not it is NOT linux_latest:
  linuxPackages_4_17 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_4_17);
  # ... and linux_latest just refers to the kernel within previously
  # defined kernelPackages_latest
  linux_latest = linuxPackages_latest.kernel;
  # ...
}

```

So what this means is that we can’t simply override `linux_latest` and get a new `linuxPackages_latest` with the overrides. We would have to override `linux_4_17` instead, which isn’t very practical if you want to stay on the latest kernel.

Instead, we need to override `linuxPackages_latest`, by using `.extend` (note the `makeExtensible` above):

```auto
{ lib, ... }:

{
  nixpkgs.overlays = lib.singleton (lib.const (super: {
    linuxPackages_latest = super.linuxPackages_latest.extend (lib.const (ksuper: {
      kernel = ksuper.kernel.override {
        extraConfig = ''
          LIRC y
        '';
      };
    }));
  }));
}

```

---

_[View the full topic](https://discourse.nixos.org/t/the-correct-way-to-override-the-latest-kernel-config/533)._
