Skip to content
This repository was archived by the owner on Mar 23, 2025. It is now read-only.
This repository was archived by the owner on Mar 23, 2025. It is now read-only.

How to override parts of the kernel package? #81

@jwillikers

Description

@jwillikers

I'm using raspberry-pi-nix as part of a flake and would like to override the kernel to apply the realtime kernel patches and enable PREEMPT_RT-related config options. I've tried a bunch of different ways of applying overlays to accomplish this, but nothing seems to be working. Here's a snippet of an overlay applied to nixpkgs.

nixpkgs.overlays = [
  (final: prev: {
    rpi-kernels.v6_6_54.bcm2712 = prev.rpi-kernels.v6_6_54.bcm2712.override (prevKernel: {
      structuredExtraConfig = with prev.lib.kernel; {
        SND_HDA_GENERIC = yes;
        SND_HDA_INTEL = yes;
        SND_HDA_PREALLOC_SIZE = 2048;

        # realtime
        # PREEMPT_RT was merged in to kernel 6.12.
        # https://github.com/NixOS/nixpkgs/blob/master/pkgs/os-specific/linux/kernel/linux-rt-6.1.nix
        PREEMPT_RT = yes;
        EXPERT = yes; # PREEMPT_RT depends on it (in kernel/Kconfig.preempt)
        # Fix error: option not set correctly: PREEMPT_VOLUNTARY (wanted 'y', got 'n').
        PREEMPT_VOLUNTARY = prev.lib.mkForce no; # PREEMPT_RT deselects it.
        # Fix error: unused option: RT_GROUP_SCHED.
        RT_GROUP_SCHED = prev.lib.mkForce (option no); # Removed by sched-disable-rt-group-sched-on-rt.patch.
        VIRTUALIZATION = no;
      };
      kernelPatches = let rt-patch = {
        name = "rt";
        patch = prev.fetchurl {
          url = "mirror://kernel/linux/kernel/projects/rt/${prevKernel.branch}/older/patch-${prevKernel.version}.patch.xz";
          sha256 = prev.lib.fakeHash;
        };
      }; in [ rt-patch ] ++ prevKernel.kernelPatches;
    });
  })
];

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions