Error returned when I try to switch to another kernel version

I’m using nixos-20.03 and has just updated my system to the latest one.

The original kernel version is 5.4.59 (i.e., pkgs.linuxPackages). After I change boot.kernelPackages from pkgs.linuxPackages to pkgs.linuxPackages_latest, and run sudo nixos-rebuild boot, an error arose.

It compalains

inconsistent kernel versions: 5.4.59
5.7.16
builder for '/nix/store/5m6cn7cib85xwjcdrnspbqibfh9cbdp8-kernel-modules.drv' failed with exit code 1

Did I do something wrong? Or what should I do to switch to a linux kernel with another version?

Thanks

Can share your configuration?

I’d look for places where you used pkgs.linuxPackages (which is always the default version) and change them to config.boot.kernelPackages (which is the configured version)

1 Like

Thanks.

The relevant part about the boot.kernelPackages is:

{ config, pkgs, ... }:

{

  boot.loader = {
    efi = {
      canTouchEfiVariables = true;
      # assuming /boot is the mount point of the  EFI partition in NixOS (as the installation section recommends).
      efiSysMountPoint = "/boot";
    };
    grub = {
      devices = [ "nodev" ];
      efiSupport = true;
      enable = true;
      useOSProber = true;
      version = 2;
    };
  };

  #####################################
  #THE FOLLOWING LINE will cause the error.#
  #####################################
  boot.kernelPackages = pkgs.linuxPackages_latest; 
  #####################################
  #ABOVE LINE causes the error.                     #
  #####################################
  boot.tmpOnTmpfs = true;
  boot.extraModulePackages = [ pkgs.linuxPackages.acpi_call ];
  boot.kernelModules = ["acpi_call" "coretemp" ];
  
  console.earlySetup = true;

  boot.kernel.sysctl={
	"net.core.wmem_max" = 24266666;
	"net.core.rmem_max" = 24266666;
  };
}

My complete configure files are placed here with some irrelvant contents removed. If you’d like to dig into the complete configure files. I place the kernel confures in bootloader.nix and in hardware-configuration.nix, there are also some contents about the kernel (which are generated by the installation program)

I’d try replacing pkgs.linuxPackages.acpi_call with config.boot.kernelPackages.acpi_call, and also do similar replacements elsewhere.

2 Likes

Thanks!
By changing pkgs.linuxPackages.acpi_call to pkgs.linuxPackages_latest.acpi_call does solve my problem.

That works, but using config.boot.kernelPackages will allow your configuration elsewhere to always track the value you set for boot.kernelPackages, so you wouldn’t need to update it in two places when you want to change the version.

Thanks, I understand your solution, which enables the module to change correspondingly with the kernel version.