Using a specific kernel version

It appears there is a bug with my GPU on kernel versions > 6.10.7, so I’d like to downgrade. I checked which kernels are available using nix repl as shown on the wiki:

pkgs.linuxPackages                           pkgs.linuxPackages_6_5                       pkgs.linuxPackages_rpi2
pkgs.linuxPackages-libre                     pkgs.linuxPackages_6_6                       pkgs.linuxPackages_rpi3
pkgs.linuxPackages-rt                        pkgs.linuxPackages_6_6_hardened              pkgs.linuxPackages_rpi4
pkgs.linuxPackages-rt_latest                 pkgs.linuxPackages_6_7                       pkgs.linuxPackages_rt_5_10
pkgs.linuxPackagesFor                        pkgs.linuxPackages_6_8                       pkgs.linuxPackages_rt_5_15
pkgs.linuxPackages_4_14                      pkgs.linuxPackages_6_9                       pkgs.linuxPackages_rt_5_4
pkgs.linuxPackages_4_19                      pkgs.linuxPackages_custom                    pkgs.linuxPackages_rt_6_1
pkgs.linuxPackages_5_10                      pkgs.linuxPackages_custom_tinyconfig_kernel  pkgs.linuxPackages_testing
pkgs.linuxPackages_5_10_hardened             pkgs.linuxPackages_hardened                  pkgs.linuxPackages_testing_bcachefs
pkgs.linuxPackages_5_15                      pkgs.linuxPackages_latest                    pkgs.linuxPackages_xanmod
pkgs.linuxPackages_5_15_hardened             pkgs.linuxPackages_latest-libre              pkgs.linuxPackages_xanmod_latest
pkgs.linuxPackages_5_4                       pkgs.linuxPackages_latest_hardened           pkgs.linuxPackages_xanmod_stable
pkgs.linuxPackages_5_4_hardened              pkgs.linuxPackages_latest_xen_dom0           pkgs.linuxPackages_xen_dom0
pkgs.linuxPackages_6_1                       pkgs.linuxPackages_latest_xen_dom0_hardened  pkgs.linuxPackages_xen_dom0_hardened
pkgs.linuxPackages_6_10                      pkgs.linuxPackages_lqx                       pkgs.linuxPackages_zen
pkgs.linuxPackages_6_11                      pkgs.linuxPackages_rpi0
pkgs.linuxPackages_6_1_hardened              pkgs.linuxPackages_rpi02w

I see that version 6.10 is available; but which version specifically is that? 6.10.2? 6.10.8? Is it possible to specify that I want 6.10.7 in configuration.nix? I tried setting pkgs.linuxPackages_6_10_7 but that didn’t work.

Oh, and I’m on the unstable channel and I’m currently using pkgs.linuxPackages_latest if that matters

I don’t have 6.10 available specifically, but choosing another example:

nix-repl> linuxPackages_6_6_hardened.kernel.version   
"6.6.51"

Naturally, since it doesn’t exist, as you can see from the repl.

Why not just use the LTS, aka the default version?

nix-repl> linuxPackages.kernel.version
"6.6.52"

I don’t have 6.10 available specifically, but choosing another example:

Thank you, apparently it’s version 6.10.11. Do you have any idea on how to use 6.10.7 instead?

Why not just use the LTS, aka the default version?

Because my hardware is pretty new (RDNA3), and the LTS kernel is too old for it.

Maybe this would work (untested)?

boot.kernelPackages = 
  let
    version = "6.10.7";
    kernel = pkgs.linuxKernel.kernels.linux_6_10.override {
      argsOverride = {
        inherit version;
        src = pkgs.fetchurl {
          url = "mirror://kernel/linux/kernel/v6.x/linux-${version}.tar.xz";
          hash = ""; # to be filled in
        };
        modDirVersion = null; # https://github.com/NixOS/nixpkgs/blob/007e91615b8127deb57ba0b08e12542abaea1c3f/pkgs/os-specific/linux/kernel/generic.nix#L44
      };
    };
  in
  pkgs.linuxKernel.packagesFor kernel;
1 Like

Thanks for pointing me in the right direction, this is what I ended up with:

boot.kernelPackages = pkgs.linuxPackagesFor (pkgs.linux_6_10.override {
	argsOverride = rec {
		src = pkgs.fetchurl {
            	url = "mirror://kernel/linux/kernel/v6.x/linux-${version}.tar.xz";
            	sha256 = "900d567ff01824708ce24c3b37faaef03e6f6145411dd447a6ff2edc8c5db3a9";
	};
	version = "6.10.7";
	modDirVersion = "6.10.7";
	};
});