My code snippet pins the linuxPackages version to 4.16 ,however i would like to follow the channel and use linuxPackages_latest as my kernel package.
Is there a way to override the linux kernel used in linuxPackages_latest ?
OP’s last question was Is there a way to override the linux kernel used in linuxPackages_latest ? The obvious answer is “Yes, override linux_latest”.
This post seemed to imply that it does not work, or is incorrect.
AFAIK, the following should work and is at least a correct way to achieve his goal. If OP finds this unsatisfying, or if it does not work, I wanted to know why, just by sheer curiosity.
Thanks for all the replies, i found the issue with the code i tried before.
I incorrectly assumed that pkgs.linux maps to the kernel which is used in boot.kernelPackages - pkgs.linux_latest is the correct thing to use here.
Special thanks to azlig for boot.kernelPatches which seems to be a cleaner approach than overriding the kernel config via packageOverrides.
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:
{
# ...
# 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):
I stumbled into this same issue recently. It seems rather unintuitive / user-unfriendly. Is there a reason why nixpkgs doesn’t define linuxPackages_latest and linux_latest (and others, such as linuxPackages and linux) like this instead: