# Pin kernel version

**URL:** https://discourse.nixos.org/t/pin-kernel-version/50630
**Category:** Uncategorized
**Created:** [August 15, 2024, 5:42am UTC](https://discourse.nixos.org/t/pin-kernel-version/50630 "2024-08-15T05:42:19Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![mvb](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/m/34f0e0/32.png) [@mvb](https://discourse.nixos.org/u/mvb)
#### Post date: [August 15, 2024, 5:42am UTC](https://discourse.nixos.org/t/pin-kernel-version/50630/1 "2024-08-15T05:42:19Z")

</div>

Till the beginning of July 2024, NixOS came with a kernel version 6.6.32. Now we’re at 6.6.45 and my audio is broken. I am _right now_ following the [official instructions](https://nixos.wiki/wiki/Linux_kernel) to install a custom kernel:

```nix
boot.kernelPackages = pkgs.linuxPackagesFor (pkgs.linux_6_6.override {
    argsOverride = rec {
      src = pkgs.fetchurl {
            url = "mirror://kernel/linux/kernel/v6.x/linux-${version}.tar.xz";
            sha256 = "0ibayrvrnw2lw7si78vdqnr20mm1d3z0g6a0ykndvgn5vdax5x9a";
      };
      version = "6.6.32";
      modDirVersion = "6.6.32";
      };
  });

```

This is no small task for my CPU. And I find it rather dumb, given that I _can_ boot into an older generation that has this kernel, but nixpks only resolve kernel versions down to the minor version, not patch.

Is there no smarter way?

---

<div class="post-metadata">

### Author: ![MagicRB](https://discourse.nixos.org/user_avatar/discourse.nixos.org/magicrb/32/6884_2.png) [@MagicRB](https://discourse.nixos.org/u/MagicRB)
#### Post date: [August 15, 2024, 5:51am UTC](https://discourse.nixos.org/t/pin-kernel-version/50630/2 "2024-08-15T05:51:15Z")

</div>

No if you’re using a different version of linux than what is exactly in the cache you will end up compiling it. No avoiding that.

---

<div class="post-metadata">

### Author: ![ElvishJerricco](https://discourse.nixos.org/user_avatar/discourse.nixos.org/elvishjerricco/32/984_2.png) [@ElvishJerricco](https://discourse.nixos.org/u/ElvishJerricco)
#### Post date: [August 15, 2024, 5:59am UTC](https://discourse.nixos.org/t/pin-kernel-version/50630/3 "2024-08-15T05:59:14Z")

</div>

And to be clear, the reason that this is a different kernel than the one from your older generation which has the same version number (assuming you meant it has the same patch version) is because _the dependencies_ of the kernel derivation have changed, so this particular build isn’t cached.

---

<div class="post-metadata">

### Author: ![mvb](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/m/34f0e0/32.png) [@mvb](https://discourse.nixos.org/u/mvb)
#### Post date: [August 15, 2024, 6:07am UTC](https://discourse.nixos.org/t/pin-kernel-version/50630/4 "2024-08-15T06:07:23Z")

</div>

Both good points. I just wonder _why_ I can’t select `linux_6_6_32`? Would that lead to too many versions in the cache? Or why isn’t that kept available?

Compilation is done by now, so it wasn’t too bad on my developer machine. And Audio is back!

---

<div class="post-metadata">

### Author: ![MagicRB](https://discourse.nixos.org/user_avatar/discourse.nixos.org/magicrb/32/6884_2.png) [@MagicRB](https://discourse.nixos.org/u/MagicRB)
#### Post date: [August 15, 2024, 6:10am UTC](https://discourse.nixos.org/t/pin-kernel-version/50630/5 "2024-08-15T06:10:15Z")

</div>

Indeed having every patch version we had would be too much compilation, caching and maintenance. Patch bumps are normally not supposed to regress, so this happens rarely.

---

<div class="post-metadata">

### Author: ![ElvishJerricco](https://discourse.nixos.org/user_avatar/discourse.nixos.org/elvishjerricco/32/984_2.png) [@ElvishJerricco](https://discourse.nixos.org/u/ElvishJerricco)
#### Post date: [August 15, 2024, 6:10am UTC](https://discourse.nixos.org/t/pin-kernel-version/50630/6 "2024-08-15T06:10:47Z")

</div>

> [@mvb](#):
>
> Would that lead to too many versions in the cache?

It’s both too many versions to have Hydra building all the time, and also just a bigger maintenance burden on nixpkgs contributors. And ideally, every new patch version is strictly superior to the last, so it is morally correct to only have the latest one. EDIT: Lol @MagicRB wrote basically the exact same thing.

If you want cached builds though, I _have_ in the past run with `boot.kernelPackages` set to a `linuxPackages` from a different nixpkgs version. I don’t necessarily recommend this, since sometimes the version of packages in nixpkgs and the version of a kernel module are interconnected, so it can lead to issues.

---

<div class="post-metadata">

### Author: ![MagicRB](https://discourse.nixos.org/user_avatar/discourse.nixos.org/magicrb/32/6884_2.png) [@MagicRB](https://discourse.nixos.org/u/MagicRB)
#### Post date: [August 15, 2024, 6:14am UTC](https://discourse.nixos.org/t/pin-kernel-version/50630/7 "2024-08-15T06:14:07Z")

</div>

@ElvishJerricco at least they know neither of us is making it up 🤣

---

<div class="post-metadata">

### Author: ![mvb](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/m/34f0e0/32.png) [@mvb](https://discourse.nixos.org/u/mvb)
#### Post date: [August 15, 2024, 6:51am UTC](https://discourse.nixos.org/t/pin-kernel-version/50630/8 "2024-08-15T06:51:42Z")

</div>

Interesting idea. But I know the issues you’re referring to from installing `kate` via home-manager that used a different version of nixpkgs than NixOS. And KDE Plasma was installed via NixOS. That broke a lot. So I think I’ll avoid that if I can. Building myself did work within reasonable time, and shouldn’t need to be done too often, so I’ll stick with this. Thanks a lot for the explanations, though 🙂
