It looks like you're encountering an issue related to kernel packages while trying to downgrade the kernel in NixOS. The error message indicates that Nix is having trouble evaluating the boot.kernelPackages attribute.
This is likely due to a couple of potential issues:
-
Invalid kernel package reference: The version you attempted to use may not exist in the current channel of Nixpkgs that you are using.
-
Nixpkgs channel state: The channel you are using may not be properly synced or may have an issue with the current version of the kernel.
Steps to Resolve the Issue
Here are steps to troubleshoot and resolve the issue:
-
Find Available Kernel Packages:
You can check available Linux kernel packages to see what versions are available. This command lists all available kernel packages:
nix-env -qaP linuxPackages
Look for versions similar to linuxPackages_5_10, or whatever version number you would like to downgrade to.
-
Update Nixpkgs Channel:
Possibly, your Nixpkgs channel needs to be updated. You can update it with:
sudo nix-channel --update
After updating the channels, try running the nix-env -qaP linuxPackages command again to see if the desired kernel versions appear.
-
Modify Your Configuration:
If you find a compatible version from the available kernel packages, adjust your configuration.nix accordingly:
{ config, pkgs, ... }:
{
boot.kernelPackages = pkgs.linuxPackages_5_10; # Replace with the correct version
}
-
Include a boot.kernel Option (if necessary):
Sometimes, it might help to specify both the kernel and kernel packages. If you want to use a specific kernel version directly, you can explicitly set boot.kernel, like this:
{ config, pkgs, ... }:
{
boot.kernelPackages = pkgs.linuxPackages_5_10; # Change to a valid version
boot.kernel = pkgs.linux_5_10; # Also specify the kernel itself if needed
}
-
Rebuild:
After making the necessary changes, rebuild the NixOS configuration:
sudo nixos-rebuild switch
-
Use --show-trace for More Details:
If it still does not work, running the rebuild command with --show-trace can provide more detailed information on what’s causing the error:
sudo nixos-rebuild switch --show-trace
Example of Downgrading Kernel
If you found a kernel version 5.10 to downgrade to, for instance, your configuration.nix might look like this:
{ config, pkgs, ... }:
{
boot.kernelPackages = pkgs.linuxPackages_5_10; # Correct version found
# Optionally specify the kernel itself
# boot.kernel = pkgs.linux_5_10;
}
Then rebuild:
sudo nixos-rebuild switch
Last Resort — Use a Stable Channel
If you're still facing issues, consider switching to a more stable channel that you know works well with the desired kernel version:
sudo nix-channel --add https://nixos.org/channels/nixos-22.05 nixos
sudo nix-channel --update
Then try to rebuild your system again.
Conclusion
Following these steps should help you successfully downgrade your kernel in NixOS. If you continue to experience issues, providing specific output from any errors encountered can help in further diagnosis.