17 # When adding a kernel:
18 # - Update packageAliases.linux_latest to the latest version
19 # - Update the rev in ../os-specific/linux/kernel/linux-libre.nix to the latest one.
20 # - Update linux_latest_hardened when the patches become available
25 deblobKernel = kernel: callPackage ../os-specific/linux/kernel/linux-libre.nix {
30 hardenedKernelFor = kernel': overrides:
32 kernel = kernel'.override overrides;
33 version = kernelPatches.hardened.${kernel.meta.branch}.version;
34 major = lib.versions.major version;
35 sha256 = kernelPatches.hardened.${kernel.meta.branch}.sha256;
36 modDirVersion' = builtins.replaceStrings [ kernel.version ] [ version ] kernel.modDirVersion;
38 structuredExtraConfig = import ../os-specific/linux/kernel/hardened/config.nix {
39 inherit stdenv lib version;
44 url = "mirror://kernel/linux/kernel/v${major}.x/linux-${version}.tar.xz";
48 kernelPatches = kernel.kernelPatches ++ [
49 kernelPatches.hardened.${kernel.meta.branch}
51 modDirVersionArg = modDirVersion' + (kernelPatches.hardened.${kernel.meta.branch}).extra;
55 kernelPatches = callPackage ../os-specific/linux/kernel/patches.nix { };
57 kernels = recurseIntoAttrs (lib.makeExtensible (self: with self;
58 let callPackage = newScope self; in {
60 # NOTE: PLEASE DO NOT ADD NEW VENDOR KERNELS TO NIXPKGS.
61 # New vendor kernels should go to nixos-hardware instead.
62 # e.g. https://github.com/NixOS/nixos-hardware/tree/master/microsoft/surface/kernel
64 linux_rpi1 = callPackage ../os-specific/linux/kernel/linux-rpi.nix {
65 kernelPatches = with kernelPatches; [
72 linux_rpi2 = callPackage ../os-specific/linux/kernel/linux-rpi.nix {
73 kernelPatches = with kernelPatches; [
80 linux_rpi3 = callPackage ../os-specific/linux/kernel/linux-rpi.nix {
81 kernelPatches = with kernelPatches; [
88 linux_rpi4 = callPackage ../os-specific/linux/kernel/linux-rpi.nix {
89 kernelPatches = with kernelPatches; [
96 linux_4_9 = throw "linux 4.9 was removed because it will reach its end of life within 22.11";
98 linux_4_14 = callPackage ../os-specific/linux/kernel/linux-4.14.nix {
100 [ kernelPatches.bridge_stp_helper
101 kernelPatches.request_key_helper
102 # See pkgs/os-specific/linux/kernel/cpu-cgroup-v2-patches/README.md
103 # when adding a new linux version
104 kernelPatches.cpu-cgroup-v2."4.11"
105 kernelPatches.modinst_arg_list_too_long
109 linux_4_19 = callPackage ../os-specific/linux/kernel/linux-4.19.nix {
111 [ kernelPatches.bridge_stp_helper
112 kernelPatches.request_key_helper
113 kernelPatches.modinst_arg_list_too_long
117 linux_5_4 = callPackage ../os-specific/linux/kernel/linux-5.4.nix {
119 kernelPatches.bridge_stp_helper
120 kernelPatches.request_key_helper
121 kernelPatches.rtl8761b_support
125 linux_rt_5_4 = callPackage ../os-specific/linux/kernel/linux-rt-5.4.nix {
127 kernelPatches.bridge_stp_helper
128 kernelPatches.request_key_helper
132 linux_5_10 = callPackage ../os-specific/linux/kernel/linux-5.10.nix {
134 kernelPatches.bridge_stp_helper
135 kernelPatches.request_key_helper
139 linux_rt_5_10 = callPackage ../os-specific/linux/kernel/linux-rt-5.10.nix {
141 kernelPatches.bridge_stp_helper
142 kernelPatches.request_key_helper
143 kernelPatches.export-rt-sched-migrate
147 linux_5_15 = callPackage ../os-specific/linux/kernel/linux-5.15.nix {
149 kernelPatches.bridge_stp_helper
150 kernelPatches.request_key_helper
154 linux_5_17 = throw "linux 5.17 was removed because it has reached its end of life upstream";
156 linux_5_18 = throw "linux 5.18 was removed because it has reached its end of life upstream";
158 linux_5_19 = throw "linux 5.19 was removed because it has reached its end of life upstream";
160 linux_6_0 = callPackage ../os-specific/linux/kernel/linux-6.0.nix {
162 kernelPatches.bridge_stp_helper
163 kernelPatches.request_key_helper
168 testing = callPackage ../os-specific/linux/kernel/linux-testing.nix {
170 kernelPatches.bridge_stp_helper
171 kernelPatches.request_key_helper
174 latest = packageAliases.linux_latest.kernel;
175 in if latest.kernelAtLeast testing.baseVersion
179 linux_testing_bcachefs = callPackage ../os-specific/linux/kernel/linux-testing-bcachefs.nix rec {
181 kernelPatches = kernel.kernelPatches;
184 linux_hardkernel_4_14 = callPackage ../os-specific/linux/kernel/linux-hardkernel-4.14.nix {
186 kernelPatches.bridge_stp_helper
187 kernelPatches.request_key_helper
188 kernelPatches.modinst_arg_list_too_long
192 # Using zenKernels like this due lqx&zen came from one source, but may have different base kernel version
193 # https://github.com/NixOS/nixpkgs/pull/161773#discussion_r820134708
194 zenKernels = callPackage ../os-specific/linux/kernel/zen-kernels.nix;
196 linux_zen = (zenKernels {
198 kernelPatches.bridge_stp_helper
199 kernelPatches.request_key_helper
203 linux_lqx = (zenKernels {
205 kernelPatches.bridge_stp_helper
206 kernelPatches.request_key_helper
210 # This contains the variants of the XanMod kernel
211 xanmodKernels = callPackage ../os-specific/linux/kernel/xanmod-kernels.nix {
213 kernelPatches.bridge_stp_helper
214 kernelPatches.request_key_helper
218 linux_xanmod = xanmodKernels.lts;
219 linux_xanmod_stable = xanmodKernels.main;
220 linux_xanmod_latest = xanmodKernels.main;
221 linux_xanmod_tt = throw "linux_xanmod_tt was removed because upstream no longer offers this option";
223 linux_libre = deblobKernel packageAliases.linux_default.kernel;
225 linux_latest_libre = deblobKernel packageAliases.linux_latest.kernel;
227 linux_hardened = hardenedKernelFor packageAliases.linux_default.kernel { };
229 linux_4_14_hardened = hardenedKernelFor kernels.linux_4_14 { };
230 linux_4_19_hardened = hardenedKernelFor kernels.linux_4_19 { };
231 linux_5_4_hardened = hardenedKernelFor kernels.linux_5_4 { };
232 linux_5_10_hardened = hardenedKernelFor kernels.linux_5_10 { };
233 linux_5_15_hardened = hardenedKernelFor kernels.linux_5_15 { };
234 linux_5_18_hardened = throw "linux 5.18 was removed because it has reached its end of life upstream";
235 linux_5_19_hardened = throw "linux 5.19 was removed because it has reached its end of life upstream";
236 linux_6_0_hardened = hardenedKernelFor kernels.linux_6_0 { };
239 /* Linux kernel modules are inherently tied to a specific kernel. So
240 rather than provide specific instances of those packages for a
241 specific kernel, we have a function that builds those packages
242 for a specific kernel. This function can then be called for
243 whatever kernel you're using. */
245 packagesFor = kernel_: lib.makeExtensible (self: with self;
246 let callPackage = newScope self; in {
249 inherit (kernel) stdenv; # in particular, use the same compiler by default
251 # to help determine module compatibility
252 inherit (kernel) isZen isHardened isLibre;
253 inherit (kernel) kernelOlder kernelAtLeast;
254 # Obsolete aliases (these packages do not depend on the kernel).
255 inherit (pkgs) odp-dpdk pktgen; # added 2018-05
256 inherit (pkgs) bcc bpftrace; # added 2021-12
258 acpi_call = callPackage ../os-specific/linux/acpi-call {};
260 akvcam = callPackage ../os-specific/linux/akvcam { };
262 amdgpu-pro = callPackage ../os-specific/linux/amdgpu-pro {
263 libffi = pkgs.libffi.overrideAttrs (orig: rec {
266 url = "https://github.com/libffi/libffi/releases/download/v${version}/${orig.pname}-${version}.tar.gz";
267 sha256 = "0mi0cpf8aa40ljjmzxb7im6dbj45bb0kllcd09xgmp834y9agyvj";
272 apfs = callPackage ../os-specific/linux/apfs { };
274 ax99100 = callPackage ../os-specific/linux/ax99100 {};
276 batman_adv = callPackage ../os-specific/linux/batman-adv {};
278 bbswitch = callPackage ../os-specific/linux/bbswitch {};
280 chipsec = callPackage ../tools/security/chipsec {
285 cryptodev = callPackage ../os-specific/linux/cryptodev { };
287 cpupower = callPackage ../os-specific/linux/cpupower { };
289 ddcci-driver = callPackage ../os-specific/linux/ddcci { };
291 dddvb = callPackage ../os-specific/linux/dddvb { };
293 digimend = callPackage ../os-specific/linux/digimend { };
295 dpdk-kmods = callPackage ../os-specific/linux/dpdk-kmods { };
297 dpdk = pkgs.dpdk.override { inherit kernel; };
299 exfat-nofuse = callPackage ../os-specific/linux/exfat { };
301 evdi = callPackage ../os-specific/linux/evdi { };
303 fwts-efi-runtime = callPackage ../os-specific/linux/fwts/module.nix { };
305 gcadapter-oc-kmod = callPackage ../os-specific/linux/gcadapter-oc-kmod { };
306 hid-nintendo = callPackage ../os-specific/linux/hid-nintendo { };
308 hyperv-daemons = callPackage ../os-specific/linux/hyperv-daemons { };
310 e1000e = if lib.versionOlder kernel.version "4.10" then callPackage ../os-specific/linux/e1000e {} else null;
312 intel-speed-select = if lib.versionAtLeast kernel.version "5.3" then callPackage ../os-specific/linux/intel-speed-select { } else null;
314 ixgbevf = callPackage ../os-specific/linux/ixgbevf {};
316 it87 = callPackage ../os-specific/linux/it87 {};
318 asus-ec-sensors = callPackage ../os-specific/linux/asus-ec-sensors {};
320 asus-wmi-sensors = callPackage ../os-specific/linux/asus-wmi-sensors {};
322 ena = callPackage ../os-specific/linux/ena {};
324 kvdo = callPackage ../os-specific/linux/kvdo {};
326 liquidtux = callPackage ../os-specific/linux/liquidtux {};
328 v4l2loopback = callPackage ../os-specific/linux/v4l2loopback { };
330 lttng-modules = callPackage ../os-specific/linux/lttng-modules { };
332 broadcom_sta = callPackage ../os-specific/linux/broadcom-sta { };
334 tbs = callPackage ../os-specific/linux/tbs { };
336 mbp2018-bridge-drv = callPackage ../os-specific/linux/mbp-modules/mbp2018-bridge-drv { };
338 new-lg4ff = callPackage ../os-specific/linux/new-lg4ff { };
340 nvidiabl = callPackage ../os-specific/linux/nvidiabl { };
342 nvidiaPackages = dontRecurseIntoAttrs (lib.makeExtensible (_: callPackage ../os-specific/linux/nvidia-x11 { }));
344 nvidia_x11 = nvidiaPackages.stable;
345 nvidia_x11_beta = nvidiaPackages.beta;
346 nvidia_x11_legacy340 = nvidiaPackages.legacy_340;
347 nvidia_x11_legacy390 = nvidiaPackages.legacy_390;
348 nvidia_x11_legacy470 = nvidiaPackages.legacy_470;
349 nvidia_x11_production = nvidiaPackages.production;
350 nvidia_x11_vulkan_beta = nvidiaPackages.vulkan_beta;
352 # this is not a replacement for nvidia_x11*
353 # only the opensource kernel driver exposed for hydra to build
354 nvidia_x11_beta_open = nvidiaPackages.beta.open;
355 nvidia_x11_production_open = nvidiaPackages.production.open;
356 nvidia_x11_stable_open = nvidiaPackages.stable.open;
357 nvidia_x11_vulkan_beta_open = nvidiaPackages.vulkan_beta.open;
359 openrazer = callPackage ../os-specific/linux/openrazer/driver.nix { };
361 ply = callPackage ../os-specific/linux/ply { };
363 r8125 = callPackage ../os-specific/linux/r8125 { };
365 r8168 = callPackage ../os-specific/linux/r8168 { };
367 rtl8188eus-aircrack = callPackage ../os-specific/linux/rtl8188eus-aircrack { };
369 rtl8192eu = callPackage ../os-specific/linux/rtl8192eu { };
371 rtl8189es = callPackage ../os-specific/linux/rtl8189es { };
373 rtl8189fs = callPackage ../os-specific/linux/rtl8189fs { };
375 rtl8723bs = callPackage ../os-specific/linux/rtl8723bs { };
377 rtl8812au = callPackage ../os-specific/linux/rtl8812au { };
379 rtl8814au = callPackage ../os-specific/linux/rtl8814au { };
381 rtl88xxau-aircrack = callPackage ../os-specific/linux/rtl88xxau-aircrack {};
383 rtl8821au = callPackage ../os-specific/linux/rtl8821au { };
385 rtl8821ce = callPackage ../os-specific/linux/rtl8821ce { };
387 rtl88x2bu = callPackage ../os-specific/linux/rtl88x2bu { };
389 rtl8821cu = callPackage ../os-specific/linux/rtl8821cu { };
391 rtw88 = callPackage ../os-specific/linux/rtw88 { };
394 rtw89 = if lib.versionOlder kernel.version "5.16" then callPackage ../os-specific/linux/rtw89 { } else null;
396 openafs_1_8 = callPackage ../servers/openafs/1.8/module.nix { };
397 # Current stable release; don't backport release updates!
398 openafs = openafs_1_8;
400 facetimehd = callPackage ../os-specific/linux/facetimehd { };
402 tuxedo-keyboard = if lib.versionAtLeast kernel.version "4.14" then callPackage ../os-specific/linux/tuxedo-keyboard { } else null;
404 jool = callPackage ../os-specific/linux/jool { };
406 kvmfr = callPackage ../os-specific/linux/kvmfr { };
408 mba6x_bl = callPackage ../os-specific/linux/mba6x_bl { };
410 mwprocapture = callPackage ../os-specific/linux/mwprocapture { };
412 mxu11x0 = callPackage ../os-specific/linux/mxu11x0 { };
414 # compiles but has to be integrated into the kernel somehow
415 # Let's have it uncommented and finish it..
416 ndiswrapper = callPackage ../os-specific/linux/ndiswrapper { };
418 netatop = callPackage ../os-specific/linux/netatop { };
420 oci-seccomp-bpf-hook = if lib.versionAtLeast kernel.version "5.4" then callPackage ../os-specific/linux/oci-seccomp-bpf-hook { } else null;
422 perf = callPackage ../os-specific/linux/kernel/perf { };
424 phc-intel = if lib.versionAtLeast kernel.version "4.10" then callPackage ../os-specific/linux/phc-intel { } else null;
426 prl-tools = callPackage ../os-specific/linux/prl-tools { };
428 sch_cake = callPackage ../os-specific/linux/sch_cake { };
430 isgx = callPackage ../os-specific/linux/isgx { };
432 rr-zen_workaround = callPackage ../development/tools/analysis/rr/zen_workaround.nix { };
434 sysdig = callPackage ../os-specific/linux/sysdig {};
436 systemtap = callPackage ../development/tools/profiling/systemtap { };
438 system76 = callPackage ../os-specific/linux/system76 { };
440 system76-acpi = callPackage ../os-specific/linux/system76-acpi { };
442 system76-power = callPackage ../os-specific/linux/system76-power { };
444 system76-io = callPackage ../os-specific/linux/system76-io { };
446 tmon = callPackage ../os-specific/linux/tmon { };
448 tp_smapi = callPackage ../os-specific/linux/tp_smapi { };
450 turbostat = callPackage ../os-specific/linux/turbostat { };
452 usbip = callPackage ../os-specific/linux/usbip { };
454 v86d = callPackage ../os-specific/linux/v86d { };
456 veikk-linux-driver = callPackage ../os-specific/linux/veikk-linux-driver { };
457 vendor-reset = callPackage ../os-specific/linux/vendor-reset { };
459 vhba = callPackage ../applications/emulators/cdemu/vhba.nix { };
461 virtio_vmmci = callPackage ../os-specific/linux/virtio_vmmci { };
463 virtualbox = callPackage ../os-specific/linux/virtualbox {
464 virtualbox = pkgs.virtualboxHardened;
467 virtualboxGuestAdditions = callPackage ../applications/virtualization/virtualbox/guest-additions {
468 virtualbox = pkgs.virtualboxHardened;
471 vm-tools = callPackage ../os-specific/linux/vm-tools { };
473 vmm_clock = callPackage ../os-specific/linux/vmm_clock { };
475 vmware = callPackage ../os-specific/linux/vmware { };
477 wireguard = if lib.versionOlder kernel.version "5.6" then callPackage ../os-specific/linux/wireguard { } else null;
479 x86_energy_perf_policy = callPackage ../os-specific/linux/x86_energy_perf_policy { };
481 xone = if lib.versionAtLeast kernel.version "5.4" then callPackage ../os-specific/linux/xone { } else null;
483 xpadneo = callPackage ../os-specific/linux/xpadneo { };
485 ithc = callPackage ../os-specific/linux/ithc { };
487 zenpower = callPackage ../os-specific/linux/zenpower { };
489 inherit (callPackage ../os-specific/linux/zfs {
490 configFile = "kernel";
492 }) zfsStable zfsUnstable;
495 can-isotp = callPackage ../os-specific/linux/can-isotp { };
497 qc71_laptop = callPackage ../os-specific/linux/qc71_laptop { };
499 hid-ite8291r3 = callPackage ../os-specific/linux/hid-ite8291r3 { };
501 } // lib.optionalAttrs config.allowAliases {
502 ati_drivers_x11 = throw "ati drivers are no longer supported by any kernel >=4.1"; # added 2021-05-18;
503 xmm7360-pci = throw "Support for the XMM7360 WWAN card was added to the iosm kmod in mainline kernel version 5.18";
506 hardenedPackagesFor = kernel: overrides: packagesFor (hardenedKernelFor kernel overrides);
509 # recurse to build modules for the kernels
510 linux_4_9 = throw "linux 4.9 was removed because it will reach its end of life within 22.11"; # Added 2022-11-08
511 linux_4_14 = recurseIntoAttrs (packagesFor kernels.linux_4_14);
512 linux_4_19 = recurseIntoAttrs (packagesFor kernels.linux_4_19);
513 linux_5_4 = recurseIntoAttrs (packagesFor kernels.linux_5_4);
514 linux_5_10 = recurseIntoAttrs (packagesFor kernels.linux_5_10);
515 linux_5_15 = recurseIntoAttrs (packagesFor kernels.linux_5_15);
516 linux_5_17 = throw "linux 5.17 was removed because it reached its end of life upstream"; # Added 2022-06-23
517 linux_5_18 = throw "linux 5.18 was removed because it reached its end of life upstream"; # Added 2022-09-17
518 linux_5_19 = throw "linux 5.19 was removed because it reached its end of life upstream"; # Added 2022-11-01
519 linux_6_0 = recurseIntoAttrs (packagesFor kernels.linux_6_0);
523 # realtime kernel packages
524 linux_rt_5_4 = packagesFor kernels.linux_rt_5_4;
525 linux_rt_5_10 = packagesFor kernels.linux_rt_5_10;
529 linux_rpi1 = packagesFor kernels.linux_rpi1;
530 linux_rpi2 = packagesFor kernels.linux_rpi2;
531 linux_rpi3 = packagesFor kernels.linux_rpi3;
532 linux_rpi4 = packagesFor kernels.linux_rpi4;
535 packages = recurseIntoAttrs (vanillaPackages // rtPackages // rpiPackages // {
537 # Intentionally lacks recurseIntoAttrs, as -rc kernels will quite likely break out-of-tree modules and cause failed Hydra builds.
538 linux_testing = packagesFor kernels.linux_testing;
539 linux_testing_bcachefs = recurseIntoAttrs (packagesFor kernels.linux_testing_bcachefs);
541 linux_hardened = recurseIntoAttrs (hardenedPackagesFor packageAliases.linux_default.kernel { });
543 linux_4_14_hardened = recurseIntoAttrs (hardenedPackagesFor kernels.linux_4_14 {
544 stdenv = gcc10Stdenv;
545 buildPackages = buildPackages // { stdenv = buildPackages.gcc10Stdenv; };
547 linux_4_19_hardened = recurseIntoAttrs (hardenedPackagesFor kernels.linux_4_19 {
548 stdenv = gcc10Stdenv;
549 buildPackages = buildPackages // { stdenv = buildPackages.gcc10Stdenv; };
551 linux_5_4_hardened = recurseIntoAttrs (hardenedPackagesFor kernels.linux_5_4 {
552 stdenv = gcc10Stdenv;
553 buildPackages = buildPackages // { stdenv = buildPackages.gcc10Stdenv; };
555 linux_5_10_hardened = recurseIntoAttrs (hardenedPackagesFor kernels.linux_5_10 { });
556 linux_5_15_hardened = recurseIntoAttrs (hardenedPackagesFor kernels.linux_5_15 { });
557 linux_5_18_hardened = throw "linux 5.18 was removed because it has reached its end of life upstream";
558 linux_5_19_hardened = throw "linux 5.19 was removed because it has reached its end of life upstream";
559 linux_6_0_hardened = recurseIntoAttrs (hardenedPackagesFor kernels.linux_6_0 { });
561 linux_zen = recurseIntoAttrs (packagesFor kernels.linux_zen);
562 linux_lqx = recurseIntoAttrs (packagesFor kernels.linux_lqx);
563 linux_xanmod = recurseIntoAttrs (packagesFor kernels.linux_xanmod);
564 linux_xanmod_stable = recurseIntoAttrs (packagesFor kernels.linux_xanmod_stable);
565 linux_xanmod_latest = recurseIntoAttrs (packagesFor kernels.linux_xanmod_latest);
566 linux_xanmod_tt = throw "linux_xanmod_tt was removed because upstream no longer offers this option";
568 hardkernel_4_14 = recurseIntoAttrs (packagesFor kernels.linux_hardkernel_4_14);
570 linux_libre = recurseIntoAttrs (packagesFor kernels.linux_libre);
572 linux_latest_libre = recurseIntoAttrs (packagesFor kernels.linux_latest_libre);
576 linux_default = packages.linux_5_15;
577 # Update this when adding the newest kernel major version!
578 linux_latest = packages.linux_6_0;
579 linux_mptcp = packages.linux_mptcp_95;
580 linux_rt_default = packages.linux_rt_5_4;
581 linux_rt_latest = packages.linux_rt_5_10;
582 linux_hardkernel_latest = packages.hardkernel_4_14;
585 manualConfig = makeOverridable (callPackage ../os-specific/linux/kernel/manual-config.nix {});
587 customPackage = { version, src, configfile, allowImportFromDerivation ? true }:
588 recurseIntoAttrs (packagesFor (manualConfig {
589 inherit version src configfile lib stdenv allowImportFromDerivation;
592 # Derive one of the default .config files
595 version ? (builtins.parseDrvName src.name).version,
596 makeTarget ? "defconfig",
597 name ? "kernel.config",
598 }: stdenvNoCC.mkDerivation {
600 depsBuildBuild = [ buildPackages.stdenv.cc ]
601 ++ lib.optionals (lib.versionAtLeast version "4.16") [ buildPackages.bison buildPackages.flex ];
603 patchShebangs scripts/
608 ARCH=${stdenv.hostPlatform.linuxArch} \
609 HOSTCC=${buildPackages.stdenv.cc.targetPrefix}gcc \
617 buildLinux = attrs: callPackage ../os-specific/linux/kernel/generic.nix attrs;