Override kernel version

I need to install exact kernel version to bisect a bug. I’ve tried to set the version in my /etc/nixos/configuration.nix like:

  nixpkgs.config.packageOverrides = pkgs : {
    linux = pkgs.linux.override {version="4.19.60";};
  };

nixos-rebuild switch doesn’t seem to do anything:

$ file /nix/var/nix/profiles/system/kernel
/nix/var/nix/profiles/system/kernel: symbolic link to /nix/store/0n0j02amv1vayml7qr7nlrl8rzrycgyf-linux-4.19.63/bzImage

How can I install the exact version?

This works for me:

boot.kernelPackages = pkgs.linuxPackagesFor (pkgs.linux_4_19.override { argsOverride = { version = "4.19.60"; }; });

This works for me:

boot.kernelPackages = pkgs.linuxPackagesFor (pkgs.linux_4_19.override { argsOverride = { version = "4.19.60"; }; });

It does? Are you sure that’s actually changing anything? How would it
know what the checksum of that kernel source?

1 Like

Ah sorry! You’re right it’s not actually building the custom version, just rebuilding the old version with the same source. I think overriding the src like this would work:

boot.kernelPackages = pkgs.linuxPackagesFor (pkgs.linux_4_19.override {
  argsOverride = rec { src = { fetchurl {
    url = "mirror://kernel/linux/kernel/v4.x/linux-${version}.tar.xz";
    sha256 = "0ibayrvrnw2lw7si78vdqnr20mm1d3z0g6a0ykndvgn5vdax5x9a";
  }; version = "4.19.60"; }; });

But can’t test it right now.

1 Like
  boot.kernelPackages = pkgs.linuxPackagesFor (pkgs.linux_4_19.override {
    argsOverride = rec {
      src = pkgs.fetchurl {
            url = "mirror://kernel/linux/kernel/v4.x/linux-${version}.tar.xz";
            sha256 = "0ibayrvrnw2lw7si78vdqnr20mm1d3z0g6a0ykndvgn5vdax5x9a";
      };
      version = "4.19.60";
      modDirVersion = "4.19.60";
      };
  });


For anyone looking the above finally worked for me, thank you for the help: )

9 Likes

OT: why does this not trigger a build error? Shouldn’t this trigger a fetch (since the hash will be different and therefore won’t be found in the store), and fail when the checksum doesn’t match?