How to pin/select the kernel version for linuxPackages_zen?

I want to use the apfs kernel driver (to access an old hackintosh partition on the host) with the zen kernel, but it appears to break on every minor version update. (Same with ddcci-driver apparently, not sure why the interface changes so often?).

So I thought I’d just somehow override with a fixed version, but it wasn’t so easy, and different from this post because the zen kernel packages attributes are themselves generated by a function.

I arrived at this but it doesn’t work yet

    kernelPackages = with pkgs; (linuxKernel.kernels.zenKernels {
      kernelPatches = [
        kernelPatches.bridge_stp_helper
        kernelPatches.request_key_helper
      ];
      zenVariant = { # here the actual target is selected based on what's available at https://github.com/zen-kernel/zen-kernel/releases
        version = "6.4.12"; #zen
        suffix = "zen1"; #zen
        sha256 = "1xxznqkgn27sh134c4szjhk8im342zh7z6200k3csnqd9fink2r7"; #zen
        isLqx = false;
      };
    }).zen;

but it gives me

       error: attribute 'extend' missing

Any ideas?

I use ddcci-driver and this drives me nuts. Figured it out today:

{ lib, pkgs, ... }:

{
  boot.kernelPackages = let
    version = "6.6.1";
    suffix = "zen1"; # use "lqx1" for linux_lqx
  in pkgs.linuxPackagesFor (pkgs.linux_zen.override {
    inherit version suffix;
    modDirVersion = lib.versions.pad 3 "${version}-${suffix}";
    src = pkgs.fetchFromGitHub {
      owner = "zen-kernel";
      repo = "zen-kernel";
      rev = "v${version}-${suffix}";
      sha256 = "13m820wggf6pkp351w06mdn2lfcwbn08ydwksyxilqb88vmr0lpq";
    };
  });
}

Note, there are newer pre-v6.8 versions (have a look at the commit history), but this one is in the NixOS binary cache, so that’s the one I picked for now.

1 Like

Hi, I was struggling with the same problem. I’m using flakes, so the above method didn’t work. And since this page was the top result in my google search, let me update my method.

I added the input URL to my flake.nix as described in NixOS & Flakes Book: https://nixos-and-flakes.thiscute.world/nixos-with-flakes/downgrade-or-upgrade-packages

nixpkgs-linux-zen_6_12_2.url = "github:NixOS/nixpkgs/028048884dc9517e548703beb24a11408cc51402";

Git commit hash value can be obtained from https://lazamar.co.uk/nix-versions/?channel=nixos-unstable&package=linux-zen.

Then I followed further steps according to “NixOS & Flakes Book” and specified the boot parameter: “boot.kernelPackages = pkgs-linux-zen_6_12_2.linuxPackages_zen;”
And it worked!

I’m new to NixOS and I’m still learning. I wish flake was the default method for configuring NixOS on the official wiki, as it reduces complexity.