Hey Nixos discourse users, I am new here and I am new to Nixos. I am having a very noobie (if that is a word) problem with my Nixos system.
To put it shortly, since the upgrade to Nixos 21.11 I have been looking to access the newer kernel (5.15 to be exact) through the use of: linuxKernel.packages.linux_5_15.nvidia_x11_legacy340
I had previously used this method of using legacy drivers: services.xserver.videoDrivers = [ "nvidia"]; hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.legacy_340;
boot.kernelPackages = pkgs.linuxPackages_5_4;
and there is nothing wrong with it, I just kinda want the newer kernel for reasons I don’t understand to be honest. As I am new I do not understand the syntax for the configuration.nix as well as i would like too so please help me install this new linux kernel with the legacy drivers as well!
Thanks to any responses/help
TLDR: Please help me install this package: linuxKernel.packages.linux_5_15.nvidia_x11_legacy340
as I would like to use the newer linux kernel.
You want to set services.xserver.videoDrivers not to nvidia, but to nvidiaLegacy340, as documented in the example there.
That will correctly set hardware.nvidia.package for your kernel version, and you can just stop specifying the kernel at all so you automatically pick the latest supported by NixOS.
As a word of warning, you may run into tons of breakage if you try linuxPackages_latest. I only try to help maintain the non-legacy nvidia, and that one already breaks on newer kernels often enough.
Edit: Nevermind, I think I got the attributes right the first time; Haven’t tested it though.
?
config.boot.kernelPackages should resolve to whichever linux kernel version you have set, and all kernel package sets have an nvidia_x11_legacy340 attribute (i.e., the package you want to install).
At that point setting either of these should do the trick:
# If you want the latest kernel always (will result
# in occasional breakage)
boot.kernelPackages = pkgs.linuxPackages_latest;
# If you want specifically 5.15, and are ok staying
# on that version until you manually upgrade
boot.kernelPackages = pkgs.linuxKernel.packages.linux_5_15;
Thank you for the quick response, after running it with your most recent recommendations I encountered problems with the building of the nvidia-340 drivers. Correct me if I am wrong but I believe this is because of the fact that the nvidia-340 drivers only support 5.4 lts and below kernel versions without significant patches.
You’re already using that package then The build failures stem from the fact that the legacy340 driver cannot run on Linux 15.5. It is still automatically packaged for all Linux kernels, nix will simply try to build the package on the fly for you - and inevitably fail because it’s unsupported. There is no secret downstream magic (currently).
This is why I would suggest not using linuxPackages_latest, unless you can assume maintenance of that driver package yourself and perhaps apply some of the patches that are floating around on the internet. I would still suggest trying linuxPackages_default, since I believe that version is actually tested to work with the drivers.
Sorry for my lack of knowledge but do I enable the default kernel by just not specifying because I tried without any specified kernel and the build failed but perhaps I am doing it wrong?
Edit: It attempted to build for kernel 5.10.81-dev
Note that you may in response get a “we can’t support that driver for newer kernels”, or “please package the patches yourself”. I don’t think there’s much interest in drivers that old.