diff --git a/nixos/modules/installer/cd-dvd/system-tarball-fuloong2f.nix b/nixos/modules/installer/cd-dvd/system-tarball-fuloong2f.nix index 123f487baf93..054c8c74a76b 100644 --- a/nixos/modules/installer/cd-dvd/system-tarball-fuloong2f.nix +++ b/nixos/modules/installer/cd-dvd/system-tarball-fuloong2f.nix @@ -93,7 +93,7 @@ in boot.initrd.availableKernelModules = [ "vfat" "reiserfs" ]; - boot.kernelPackages = pkgs.linuxPackages_3_10; + boot.kernelPackages = pkgs.linuxKernel.packages.linux_3_10; boot.kernelParams = [ "console=tty1" ]; boot.postBootCommands = diff --git a/nixos/modules/installer/cd-dvd/system-tarball-pc.nix b/nixos/modules/installer/cd-dvd/system-tarball-pc.nix index a79209d7dfef..674fb6c8a33c 100644 --- a/nixos/modules/installer/cd-dvd/system-tarball-pc.nix +++ b/nixos/modules/installer/cd-dvd/system-tarball-pc.nix @@ -114,7 +114,7 @@ in # To be able to use the systemTarball to catch troubles. boot.crashDump = { enable = true; - kernelPackages = pkgs.linuxPackages_3_4; + kernelPackages = pkgs.linuxKernel.packages.linux_3_4; }; # No grub for the tarball. diff --git a/nixos/modules/installer/cd-dvd/system-tarball-sheevaplug.nix b/nixos/modules/installer/cd-dvd/system-tarball-sheevaplug.nix index 95579f3ca06d..458e313a3f75 100644 --- a/nixos/modules/installer/cd-dvd/system-tarball-sheevaplug.nix +++ b/nixos/modules/installer/cd-dvd/system-tarball-sheevaplug.nix @@ -111,7 +111,7 @@ in # "console=ttyS0,115200n8" # serial console ]; - boot.kernelPackages = pkgs.linuxPackages_3_4; + boot.kernelPackages = pkgs.linuxKernel.packages.linux_3_4; boot.supportedFilesystems = [ "reiserfs" ]; diff --git a/nixos/modules/installer/sd-card/sd-image-raspberrypi.nix b/nixos/modules/installer/sd-card/sd-image-raspberrypi.nix index 83850f4c1158..103d6787a03c 100644 --- a/nixos/modules/installer/sd-card/sd-image-raspberrypi.nix +++ b/nixos/modules/installer/sd-card/sd-image-raspberrypi.nix @@ -12,7 +12,7 @@ boot.loader.generic-extlinux-compatible.enable = true; boot.consoleLogLevel = lib.mkDefault 7; - boot.kernelPackages = pkgs.linuxPackages_rpi1; + boot.kernelPackages = pkgs.linuxKernel.packages.linux_rpi1; sdImage = { populateFirmwareCommands = let diff --git a/nixos/modules/system/boot/kernel.nix b/nixos/modules/system/boot/kernel.nix index 1a6a9d99d5bb..15a5fd236092 100644 --- a/nixos/modules/system/boot/kernel.nix +++ b/nixos/modules/system/boot/kernel.nix @@ -47,7 +47,7 @@ in # We don't want to evaluate all of linuxPackages for the manual # - some of it might not even evaluate correctly. defaultText = "pkgs.linuxPackages"; - example = literalExample "pkgs.linuxPackages_2_6_25"; + example = literalExample "pkgs.linuxKernel.packages.linux_5_10"; description = '' This option allows you to override the Linux kernel used by NixOS. Since things like external kernel module packages are diff --git a/nixos/tests/kernel-generic.nix b/nixos/tests/kernel-generic.nix index cd32049dff46..6511d8db5b77 100644 --- a/nixos/tests/kernel-generic.nix +++ b/nixos/tests/kernel-generic.nix @@ -23,16 +23,18 @@ let assert "${linuxPackages.kernel.modDirVersion}" in machine.succeed("uname -a") ''; }) args); + + packages = pkgs.linuxKernel.packages; in with pkgs; { - linux_4_4 = makeKernelTest "4.4" linuxPackages_4_4; - linux_4_9 = makeKernelTest "4.9" linuxPackages_4_9; - linux_4_14 = makeKernelTest "4.14" linuxPackages_4_14; - linux_4_19 = makeKernelTest "4.19" linuxPackages_4_19; - linux_5_4 = makeKernelTest "5.4" linuxPackages_5_4; - linux_5_10 = makeKernelTest "5.10" linuxPackages_5_10; - linux_5_12 = makeKernelTest "5.12" linuxPackages_5_12; - linux_5_13 = makeKernelTest "5.13" linuxPackages_5_13; + linux_4_4 = makeKernelTest "4.4" packages.linux_4_4; + linux_4_9 = makeKernelTest "4.9" packages.linux_4_9; + linux_4_14 = makeKernelTest "4.14" packages.linux_4_14; + linux_4_19 = makeKernelTest "4.19" packages.linux_4_19; + linux_5_4 = makeKernelTest "5.4" packages.linux_5_4; + linux_5_10 = makeKernelTest "5.10" packages.linux_5_10; + linux_5_12 = makeKernelTest "5.12" packages.linux_5_12; + linux_5_13 = makeKernelTest "5.13" packages.linux_5_13; linux_testing = makeKernelTest "testing" linuxPackages_testing; } diff --git a/pkgs/os-specific/linux/zfs/default.nix b/pkgs/os-specific/linux/zfs/default.nix index 517e6036e780..6f0f32d5230b 100644 --- a/pkgs/os-specific/linux/zfs/default.nix +++ b/pkgs/os-specific/linux/zfs/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetchFromGitHub +{ pkgs, lib, stdenv, fetchFromGitHub , autoreconfHook269, util-linux, nukeReferences, coreutils , perl, nixosTests , configFile ? "all" @@ -16,7 +16,7 @@ , enablePython ? true # for determining the latest compatible linuxPackages -, linuxPackages_5_13 +, linuxPackages_5_13 ? pkgs.linuxKernel.packages.linux_5_13 }: with lib; diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix index 87c582987468..ef18a4aa927c 100644 --- a/pkgs/top-level/aliases.nix +++ b/pkgs/top-level/aliases.nix @@ -435,8 +435,40 @@ mapAliases ({ libwnck3 = libwnck; lilypond-unstable = lilypond; # added 2021-03-11 links = links2; # added 2016-01-31 - linux_rpi0 = linux_rpi1; - linuxPackages_rpi0 = linuxPackages_rpi1; + linux_rpi0 = linuxKernel.kernels.linux_rpi1; + linuxPackages_rpi0 = linuxKernel.packages.linux_rpi1; + linuxPackages_rt_5_4 = linuxKernel.packages.linux_rt_5_4; + linuxPackages_rt_5_10 = linuxKernel.packages.linux_rt_5_10; + linuxPackages_rt_5_11 = linuxKernel.packages.linux_rt_5_11; + linuxPackages_rpi1 = linuxKernel.packages.linux_rpi1; + linuxPackages_rpi2 = linuxKernel.packages.linux_rpi2; + linuxPackages_rpi3 = linuxKernel.packages.linux_rpi3; + linuxPackages_rpi4 = linuxKernel.packages.linux_rpi4; + linuxPackages_4_4 = linuxKernel.packages.linux_4_4; + linuxPackages_4_9 = linuxKernel.packages.linux_4_9; + linuxPackages_4_14 = linuxKernel.packages.linux_4_14; + linuxPackages_hardkernel_4_14 = linuxKernel.packages.hardkernel_4_14; + linuxPackages_4_19 = linuxKernel.packages.linux_4_19; + linuxPackages_5_4 = linuxKernel.packages.linux_5_4; + linuxPackages_5_10 = linuxKernel.packages.linux_5_10; + linuxPackages_5_12 = linuxKernel.packages.linux_5_12; + linuxPackages_5_13 = linuxKernel.packages.linux_5_13; + + linux_mptcp_95 = linuxKernel.kernels.linux_mptcp_95; + linux_rpi1 = linuxKernel.kernels.linux_rpi1; + linux_rpi2 = linuxKernel.kernels.linux_rpi2; + linux_rpi3 = linuxKernel.kernels.linux_rpi3; + linux_rpi4 = linuxKernel.kernels.linux_rpi4; + linux_4_4 = linuxKernel.kernels.linux_4_4; + linux_4_9 = linuxKernel.kernels.linux_4_9; + linux_4_14 = linuxKernel.kernels.linux_4_14; + linux_4_19 = linuxKernel.kernels.linux_4_19; + linux_5_4 = linuxKernel.kernels.linux_5_4; + linux-rt_5_4 = linuxKernel.kernels.linux_rt_5_4; + linux_5_10 = linuxKernel.kernels.linux_5_10; + linux-rt_5_10 = linuxKernel.kernels.linux_rt_5_10; + linux_5_12 = linuxKernel.kernels.linux_5_12; + linux-rt_5_11 = linuxKernel.kernels.linux_rt_5_11; # added 2020-04-04 linuxPackages_testing_hardened = throw "linuxPackages_testing_hardened has been removed, please use linuxPackages_latest_hardened"; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index d8cc410c3385..48f98f2fb768 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -21045,465 +21045,31 @@ with pkgs; tgt = callPackage ../tools/networking/tgt { }; - # -- Linux kernel expressions ------------------------------------------------ - lkl = callPackage ../applications/virtualization/lkl { }; inherit (callPackages ../os-specific/linux/kernel-headers { }) linuxHeaders makeLinuxHeaders; - kernelPatches = callPackage ../os-specific/linux/kernel/patches.nix { }; - klibc = callPackage ../os-specific/linux/klibc { }; klibcShrunk = lowPrio (callPackage ../os-specific/linux/klibc/shrunk.nix { }); - linux_mptcp = linux_mptcp_95; + linuxKernel = recurseIntoAttrs (callPackage ./linux-kernels.nix { }); - linux_mptcp_95 = callPackage ../os-specific/linux/kernel/linux-mptcp-95.nix { - kernelPatches = linux_4_19.kernelPatches; - }; + inherit (linuxKernel) buildLinux linuxConfig kernelPatches; - linux_rpi1 = callPackage ../os-specific/linux/kernel/linux-rpi.nix { - kernelPatches = with kernelPatches; [ - bridge_stp_helper - request_key_helper - ]; - rpiVersion = 1; - }; + linuxPackagesFor = linuxKernel.packagesFor; - linux_rpi2 = callPackage ../os-specific/linux/kernel/linux-rpi.nix { - kernelPatches = with kernelPatches; [ - bridge_stp_helper - request_key_helper - ]; - rpiVersion = 2; - }; + hardenedLinuxPackagesFor = linuxKernel.hardenedPackagesFor; - linux_rpi3 = callPackage ../os-specific/linux/kernel/linux-rpi.nix { - kernelPatches = with kernelPatches; [ - bridge_stp_helper - request_key_helper - ]; - rpiVersion = 3; - }; + linuxManualConfig = linuxKernel.manualConfig; - linux_rpi4 = callPackage ../os-specific/linux/kernel/linux-rpi.nix { - kernelPatches = with kernelPatches; [ - bridge_stp_helper - request_key_helper - ]; - rpiVersion = 4; - }; - - linux_4_4 = callPackage ../os-specific/linux/kernel/linux-4.4.nix { - kernelPatches = - [ kernelPatches.bridge_stp_helper - kernelPatches.request_key_helper_updated - kernelPatches.cpu-cgroup-v2."4.4" - kernelPatches.modinst_arg_list_too_long - ]; - }; - - linux_4_9 = callPackage ../os-specific/linux/kernel/linux-4.9.nix { - kernelPatches = - [ kernelPatches.bridge_stp_helper - kernelPatches.request_key_helper_updated - kernelPatches.cpu-cgroup-v2."4.9" - kernelPatches.modinst_arg_list_too_long - ]; - }; - - linux_4_14 = callPackage ../os-specific/linux/kernel/linux-4.14.nix { - kernelPatches = - [ kernelPatches.bridge_stp_helper - kernelPatches.request_key_helper - # See pkgs/os-specific/linux/kernel/cpu-cgroup-v2-patches/README.md - # when adding a new linux version - kernelPatches.cpu-cgroup-v2."4.11" - kernelPatches.modinst_arg_list_too_long - ]; - }; - - linux_4_19 = callPackage ../os-specific/linux/kernel/linux-4.19.nix { - kernelPatches = - [ kernelPatches.bridge_stp_helper - kernelPatches.request_key_helper - kernelPatches.modinst_arg_list_too_long - ]; - }; - - linux_5_4 = callPackage ../os-specific/linux/kernel/linux-5.4.nix { - kernelPatches = [ - kernelPatches.bridge_stp_helper - kernelPatches.request_key_helper - kernelPatches.rtl8761b_support - ]; - }; - - linux-rt_5_4 = callPackage ../os-specific/linux/kernel/linux-rt-5.4.nix { - kernelPatches = [ - kernelPatches.bridge_stp_helper - kernelPatches.request_key_helper - ]; - }; - - linux_5_10 = callPackage ../os-specific/linux/kernel/linux-5.10.nix { - kernelPatches = [ - kernelPatches.bridge_stp_helper - kernelPatches.request_key_helper - ]; - }; - - linux_5_12 = callPackage ../os-specific/linux/kernel/linux-5.12.nix { - kernelPatches = [ - kernelPatches.bridge_stp_helper - kernelPatches.request_key_helper - ]; - }; - - linux_5_13 = callPackage ../os-specific/linux/kernel/linux-5.13.nix { - kernelPatches = [ - kernelPatches.bridge_stp_helper - kernelPatches.request_key_helper - ]; - }; - - linux-rt_5_10 = callPackage ../os-specific/linux/kernel/linux-rt-5.10.nix { - kernelPatches = [ - kernelPatches.bridge_stp_helper - kernelPatches.request_key_helper - kernelPatches.export-rt-sched-migrate - ]; - }; - - linux-rt_5_11 = callPackage ../os-specific/linux/kernel/linux-rt-5.11.nix { - kernelPatches = [ - kernelPatches.bridge_stp_helper - kernelPatches.request_key_helper - kernelPatches.export-rt-sched-migrate - ]; - }; - - linux_testing = callPackage ../os-specific/linux/kernel/linux-testing.nix { - kernelPatches = [ - kernelPatches.bridge_stp_helper - kernelPatches.request_key_helper - ]; - }; - - linux_testing_bcachefs = callPackage ../os-specific/linux/kernel/linux-testing-bcachefs.nix rec { - kernel = linux_5_13; - kernelPatches = kernel.kernelPatches; - }; - - linux_hardkernel_4_14 = callPackage ../os-specific/linux/kernel/linux-hardkernel-4.14.nix { - kernelPatches = [ - kernelPatches.bridge_stp_helper - kernelPatches.request_key_helper - kernelPatches.modinst_arg_list_too_long - ]; - }; - - linux_zen = callPackage ../os-specific/linux/kernel/linux-zen.nix { - kernelPatches = [ - kernelPatches.bridge_stp_helper - kernelPatches.request_key_helper - ]; - }; - - linux_lqx = callPackage ../os-specific/linux/kernel/linux-lqx.nix { - kernelPatches = [ - kernelPatches.bridge_stp_helper - kernelPatches.request_key_helper - ]; - }; - - linux_xanmod = callPackage ../os-specific/linux/kernel/linux-xanmod.nix { - kernelPatches = [ - kernelPatches.bridge_stp_helper - kernelPatches.request_key_helper - ]; - }; - - /* Linux kernel modules are inherently tied to a specific kernel. So - rather than provide specific instances of those packages for a - specific kernel, we have a function that builds those packages - for a specific kernel. This function can then be called for - whatever kernel you're using. */ - - linuxPackagesFor = kernel_: lib.makeExtensible (self: with self; { - callPackage = newScope self; - - kernel = kernel_; - inherit (kernel) stdenv; # in particular, use the same compiler by default - - # to help determine module compatibility - inherit (kernel) isZen isHardened isLibre; - inherit (kernel) kernelOlder kernelAtLeast; - - # Obsolete aliases (these packages do not depend on the kernel). - inherit (pkgs) odp-dpdk pktgen; # added 2018-05 - - acpi_call = callPackage ../os-specific/linux/acpi-call {}; - - akvcam = callPackage ../os-specific/linux/akvcam { - inherit (qt5) qmake; - }; - - amdgpu-pro = callPackage ../os-specific/linux/amdgpu-pro { }; - - anbox = callPackage ../os-specific/linux/anbox/kmod.nix { }; - - apfs = callPackage ../os-specific/linux/apfs { }; - - batman_adv = callPackage ../os-specific/linux/batman-adv {}; - - bcc = callPackage ../os-specific/linux/bcc { - python = python3; - }; - - bpftrace = callPackage ../os-specific/linux/bpftrace { }; - - bbswitch = callPackage ../os-specific/linux/bbswitch {}; - - chipsec = callPackage ../tools/security/chipsec { - inherit kernel; - withDriver = true; - }; - - cryptodev = callPackage ../os-specific/linux/cryptodev { }; - - cpupower = callPackage ../os-specific/linux/cpupower { }; - - ddcci-driver = callPackage ../os-specific/linux/ddcci { }; - - digimend = callPackage ../os-specific/linux/digimend { }; - - dpdk-kmods = callPackage ../os-specific/linux/dpdk-kmods { }; - - exfat-nofuse = callPackage ../os-specific/linux/exfat { }; - - evdi = callPackage ../os-specific/linux/evdi { }; - - fwts-efi-runtime = callPackage ../os-specific/linux/fwts/module.nix { }; - - gcadapter-oc-kmod = callPackage ../os-specific/linux/gcadapter-oc-kmod { }; - - hid-nintendo = callPackage ../os-specific/linux/hid-nintendo { }; - - hyperv-daemons = callPackage ../os-specific/linux/hyperv-daemons { }; - - e1000e = if lib.versionOlder kernel.version "4.10" then callPackage ../os-specific/linux/e1000e {} else null; - - intel-speed-select = if lib.versionAtLeast kernel.version "5.3" then callPackage ../os-specific/linux/intel-speed-select { } else null; - - ixgbevf = callPackage ../os-specific/linux/ixgbevf {}; - - it87 = callPackage ../os-specific/linux/it87 {}; - - asus-wmi-sensors = callPackage ../os-specific/linux/asus-wmi-sensors {}; - - ena = callPackage ../os-specific/linux/ena {}; - - v4l2loopback = callPackage ../os-specific/linux/v4l2loopback { }; - - lttng-modules = callPackage ../os-specific/linux/lttng-modules { }; - - broadcom_sta = callPackage ../os-specific/linux/broadcom-sta { }; - - tbs = callPackage ../os-specific/linux/tbs { }; - - mbp2018-bridge-drv = callPackage ../os-specific/linux/mbp-modules/mbp2018-bridge-drv { }; - - nvidiabl = callPackage ../os-specific/linux/nvidiabl { }; - - nvidiaPackages = dontRecurseIntoAttrs (callPackage ../os-specific/linux/nvidia-x11 { }); - - nvidia_x11_legacy340 = nvidiaPackages.legacy_340; - nvidia_x11_legacy390 = nvidiaPackages.legacy_390; - nvidia_x11_beta = nvidiaPackages.beta; - nvidia_x11_vulkan_beta = nvidiaPackages.vulkan_beta; - nvidia_x11 = nvidiaPackages.stable; - - openrazer = callPackage ../os-specific/linux/openrazer/driver.nix { }; - - ply = callPackage ../os-specific/linux/ply { }; - - r8125 = callPackage ../os-specific/linux/r8125 { }; - - r8168 = callPackage ../os-specific/linux/r8168 { }; - - rtl8188eus-aircrack = callPackage ../os-specific/linux/rtl8188eus-aircrack { }; - - rtl8192eu = callPackage ../os-specific/linux/rtl8192eu { }; - - rtl8723bs = callPackage ../os-specific/linux/rtl8723bs { }; - - rtl8812au = callPackage ../os-specific/linux/rtl8812au { }; - - rtl8814au = callPackage ../os-specific/linux/rtl8814au { }; - - rtl88xxau-aircrack = callPackage ../os-specific/linux/rtl88xxau-aircrack { }; - - rtl8821au = callPackage ../os-specific/linux/rtl8821au { }; - - rtl8821ce = callPackage ../os-specific/linux/rtl8821ce { }; - - rtl88x2bu = callPackage ../os-specific/linux/rtl88x2bu { }; - - rtl8821cu = callPackage ../os-specific/linux/rtl8821cu { }; - - rtw88 = callPackage ../os-specific/linux/rtw88 { }; - rtlwifi_new = rtw88; - - rtw89 = callPackage ../os-specific/linux/rtw89 { }; - - openafs_1_8 = callPackage ../servers/openafs/1.8/module.nix { }; - openafs_1_9 = callPackage ../servers/openafs/1.9/module.nix { }; - # Current stable release; don't backport release updates! - openafs = openafs_1_8; - - facetimehd = callPackage ../os-specific/linux/facetimehd { }; - - tuxedo-keyboard = if lib.versionAtLeast kernel.version "4.14" then callPackage ../os-specific/linux/tuxedo-keyboard { } else null; - - jool = callPackage ../os-specific/linux/jool { }; - - kvmfr = callPackage ../os-specific/linux/kvmfr { }; - - mba6x_bl = callPackage ../os-specific/linux/mba6x_bl { }; - - mwprocapture = callPackage ../os-specific/linux/mwprocapture { }; - - mxu11x0 = callPackage ../os-specific/linux/mxu11x0 { }; - - # compiles but has to be integrated into the kernel somehow - # Let's have it uncommented and finish it.. - ndiswrapper = callPackage ../os-specific/linux/ndiswrapper { }; - - netatop = callPackage ../os-specific/linux/netatop { }; - - oci-seccomp-bpf-hook = if lib.versionAtLeast kernel.version "5.4" then callPackage ../os-specific/linux/oci-seccomp-bpf-hook { } else null; - - perf = if lib.versionAtLeast kernel.version "3.12" then callPackage ../os-specific/linux/kernel/perf.nix { } else null; - - phc-intel = if lib.versionAtLeast kernel.version "4.10" then callPackage ../os-specific/linux/phc-intel { } else null; - - # Disable for kernels 4.15 and above due to compatibility issues - prl-tools = if lib.versionOlder kernel.version "4.15" then callPackage ../os-specific/linux/prl-tools { } else null; - - sch_cake = callPackage ../os-specific/linux/sch_cake { }; - - isgx = callPackage ../os-specific/linux/isgx { }; - - sysdig = callPackage ../os-specific/linux/sysdig {}; - - systemtap = callPackage ../development/tools/profiling/systemtap { }; - - system76 = callPackage ../os-specific/linux/system76 { }; - - system76-acpi = callPackage ../os-specific/linux/system76-acpi { }; - - system76-power = callPackage ../os-specific/linux/system76-power { }; - - system76-io = callPackage ../os-specific/linux/system76-io { }; - - tmon = callPackage ../os-specific/linux/tmon { }; - - tp_smapi = callPackage ../os-specific/linux/tp_smapi { }; - - turbostat = callPackage ../os-specific/linux/turbostat { }; - - usbip = callPackage ../os-specific/linux/usbip { }; - - v86d = callPackage ../os-specific/linux/v86d { }; - - veikk-linux-driver = callPackage ../os-specific/linux/veikk-linux-driver { }; - - vendor-reset = callPackage ../os-specific/linux/vendor-reset { }; - - vhba = callPackage ../misc/emulators/cdemu/vhba.nix { }; - - virtualbox = callPackage ../os-specific/linux/virtualbox { - virtualbox = pkgs.virtualboxHardened; - }; - - virtualboxGuestAdditions = callPackage ../applications/virtualization/virtualbox/guest-additions { - virtualbox = pkgs.virtualboxHardened; - }; - - wireguard = if lib.versionOlder kernel.version "5.6" then callPackage ../os-specific/linux/wireguard { } else null; - - x86_energy_perf_policy = callPackage ../os-specific/linux/x86_energy_perf_policy { }; - - xmm7360-pci = callPackage ../os-specific/linux/xmm7360-pci { }; - - xpadneo = callPackage ../os-specific/linux/xpadneo { }; - - zenpower = callPackage ../os-specific/linux/zenpower { }; - - inherit (callPackages ../os-specific/linux/zfs { - configFile = "kernel"; - inherit kernel; - }) zfsStable zfsUnstable; - zfs = zfsStable; - - can-isotp = callPackage ../os-specific/linux/can-isotp { }; - } // lib.optionalAttrs (config.allowAliases or false) { - # aliases or removed packages - ati_drivers_x11 = throw "ati drivers are no longer supported by any kernel >=4.1"; # added 2021-05-18 - }); - - # The current default kernel / kernel modules. - linuxPackages = linuxPackages_5_10; - linux = linuxPackages.kernel; - - # Update this when adding the newest kernel major version! - # And update linux_latest_for_hardened below if the patches are already available - linuxPackages_latest = linuxPackages_5_13; - linux_latest = linuxPackages_latest.kernel; - - # Realtime kernel packages. - linuxPackages-rt_5_4 = linuxPackagesFor pkgs.linux-rt_5_4; - linuxPackages-rt_5_10 = linuxPackagesFor pkgs.linux-rt_5_10; - linuxPackages-rt_5_11 = linuxPackagesFor pkgs.linux-rt_5_11; - linuxPackages-rt = linuxPackages-rt_5_4; - linuxPackages-rt_latest = linuxPackages-rt_5_11; - linux-rt = linuxPackages-rt.kernel; - linux-rt_latest = linuxPackages-rt_latest.kernel; - - linuxPackages_mptcp = linuxPackagesFor pkgs.linux_mptcp; - linuxPackages_rpi1 = linuxPackagesFor pkgs.linux_rpi1; - linuxPackages_rpi2 = linuxPackagesFor pkgs.linux_rpi2; - linuxPackages_rpi3 = linuxPackagesFor pkgs.linux_rpi3; - linuxPackages_rpi4 = linuxPackagesFor pkgs.linux_rpi4; - # Build kernel modules for some of the kernels. - linuxPackages_4_4 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_4_4); - linuxPackages_4_9 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_4_9); - linuxPackages_4_14 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_4_14); - linuxPackages_4_19 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_4_19); - linuxPackages_5_4 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_5_4); - linuxPackages_5_10 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_5_10); - linuxPackages_5_12 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_5_12); - linuxPackages_5_13 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_5_13); - - # When adding to the list above: - # - Update linuxPackages_latest to the latest version - # - Update the rev in ../os-specific/linux/kernel/linux-libre.nix to the latest one. - - # Intentionally lacks recurseIntoAttrs, as -rc kernels will quite likely break out-of-tree modules and cause failed Hydra builds. - linuxPackages_testing = linuxPackagesFor pkgs.linux_testing; - - linuxPackages_custom = { version, src, configfile, allowImportFromDerivation ? true }: - recurseIntoAttrs (linuxPackagesFor (pkgs.linuxManualConfig { - inherit version src configfile lib stdenv allowImportFromDerivation; - })); + linuxPackages_custom = linuxKernel.customPackage; # This serves as a test for linuxPackages_custom linuxPackages_custom_tinyconfig_kernel = let base = pkgs.linuxPackages.kernel; - tinyLinuxPackages = pkgs.linuxPackages_custom { + tinyLinuxPackages = linuxKernel.customPackage { inherit (base) version src; allowImportFromDerivation = false; configfile = pkgs.linuxConfig { @@ -21513,83 +21079,54 @@ with pkgs; }; in tinyLinuxPackages.kernel; - # Build a kernel with bcachefs module - linuxPackages_testing_bcachefs = recurseIntoAttrs (linuxPackagesFor pkgs.linux_testing_bcachefs); + # The current default kernel / kernel modules. + linuxPackages = linuxKernel.packageAliases.linux_default; + linux = linuxPackages.kernel; - # Hardened Linux - hardenedLinuxPackagesFor = kernel': overrides: - let # Note: We use this hack since the hardened patches can lag behind and we don't want to delay updates: - linux_latest_for_hardened = pkgs.linux_5_12; - kernel = (if kernel' == pkgs.linux_latest then linux_latest_for_hardened else kernel').override overrides; - in linuxPackagesFor (kernel.override { - structuredExtraConfig = import ../os-specific/linux/kernel/hardened/config.nix { - inherit lib; - inherit (kernel) version; - }; - kernelPatches = kernel.kernelPatches ++ [ - kernelPatches.hardened.${kernel.meta.branch} - ]; - modDirVersionArg = kernel.modDirVersion + (kernelPatches.hardened.${kernel.meta.branch}).extra; - isHardened = true; - }); + linuxPackages_latest = linuxKernel.packageAliases.linux_latest; + linux_latest = linuxPackages_latest.kernel; - linuxPackages_hardened = recurseIntoAttrs (hardenedLinuxPackagesFor pkgs.linux { }); + # Testing (rc) kernel + linuxPackages_testing = linuxKernel.packages.linux_testing; + linux_testing = linuxKernel.kernels.linux_testing; + + linuxPackages_testing_bcachefs = linuxKernel.packages.linux_testing_bcachefs; + linux_testing_bcachefs = linuxKernel.kernels.linux_testing_bcachefs; + + # kernel with mtcp support + linuxPackages_mptcp = linuxKernel.packageAliases.linux_mptcp; + linux_mptcp = linuxPackages_mptcp.kernel; + + # Realtime kernel + linuxPackages-rt = linuxKernel.packageAliases.linux_rt_default; + linuxPackages-rt_latest = linuxKernel.packageAliases.linux_rt_latest; + linux-rt = linuxPackages-rt.kernel; + linux-rt_latest = linuxPackages-rt_latest.kernel; + + # hardened kernels + linuxPackages_hardened = linuxKernel.packages.linux_hardened; linux_hardened = linuxPackages_hardened.kernel; - - linuxPackages_latest_hardened = recurseIntoAttrs (hardenedLinuxPackagesFor pkgs.linux_latest { }); + linuxPackages_latest_hardened = linuxKernel.packages.linux_latest_hardened; linux_latest_hardened = linuxPackages_latest_hardened.kernel; # Hardkernel (Odroid) kernels. - linuxPackages_hardkernel_4_14 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_hardkernel_4_14); - linuxPackages_hardkernel_latest = linuxPackages_hardkernel_4_14; + linuxPackages_hardkernel_latest = linuxKernel.packageAliases.linux_hardkernel_latest; linux_hardkernel_latest = linuxPackages_hardkernel_latest.kernel; # GNU Linux-libre kernels - linuxPackages-libre = recurseIntoAttrs (linuxPackagesFor linux-libre); - linux-libre = callPackage ../os-specific/linux/kernel/linux-libre.nix {}; - linuxPackages_latest-libre = recurseIntoAttrs (linuxPackagesFor linux_latest-libre); - linux_latest-libre = linux-libre.override { linux = linux_latest; }; + linuxPackages-libre = linuxKernel.packages.linux_libre; + linux-libre = linuxPackages-libre.kernel; + linuxPackages_latest-libre = linuxKernel.packages.linux_latest_libre; + linux_latest-libre = linuxPackages_latest-libre.kernel; # zen-kernel - linuxPackages_zen = recurseIntoAttrs (linuxPackagesFor pkgs.linux_zen); - linuxPackages_lqx = recurseIntoAttrs (linuxPackagesFor pkgs.linux_lqx); + linuxPackages_zen = linuxKernel.packages.linux_zen; + linuxPackages_lqx = linuxKernel.packages.linux_lqx; # XanMod kernel - linuxPackages_xanmod = recurseIntoAttrs (linuxPackagesFor pkgs.linux_xanmod); + linuxPackages_xanmod = linuxKernel.packages.linux_xanmod; - # A function to build a manually-configured kernel - linuxManualConfig = makeOverridable (callPackage ../os-specific/linux/kernel/manual-config.nix {}); - - # Derive one of the default .config files - linuxConfig = { - src, - version ? (builtins.parseDrvName src.name).version, - makeTarget ? "defconfig", - name ? "kernel.config", - }: stdenvNoCC.mkDerivation { - inherit name src; - depsBuildBuild = [ buildPackages.stdenv.cc ] - ++ lib.optionals (lib.versionAtLeast version "4.16") [ buildPackages.bison buildPackages.flex ]; - postPatch = '' - patchShebangs scripts/ - ''; - buildPhase = '' - ( - set -x - make \ - ARCH=${stdenv.hostPlatform.linuxArch} \ - HOSTCC=${buildPackages.stdenv.cc.targetPrefix}gcc \ - ${makeTarget} - ) - ''; - installPhase = '' - cp .config $out - ''; - }; - - buildLinux = attrs: callPackage ../os-specific/linux/kernel/generic.nix attrs; - - cryptodev = linuxPackages_4_9.cryptodev; + cryptodev = linuxKernel.packages.linux_4_9.cryptodev; dpdk = callPackage ../os-specific/linux/dpdk { kernel = null; # dpdk modules are in linuxPackages.dpdk.kmod diff --git a/pkgs/top-level/linux-kernels.nix b/pkgs/top-level/linux-kernels.nix new file mode 100644 index 000000000000..86d451865957 --- /dev/null +++ b/pkgs/top-level/linux-kernels.nix @@ -0,0 +1,546 @@ +{ pkgs +, config +, buildPackages +, callPackage +, makeOverridable +, recurseIntoAttrs +, dontRecurseIntoAttrs +, stdenv +, stdenvNoCC +, newScope +, lib +}: + +# When adding a kernel: + # - Update packageAliases.linux_latest to the latest version + # - Update the rev in ../os-specific/linux/kernel/linux-libre.nix to the latest one. + # - Update linux_latest_hardened when the patches become available + +let + kernelPatches = callPackage ../os-specific/linux/kernel/patches.nix { }; + + deblobKernel = kernel: callPackage ../os-specific/linux/kernel/linux-libre.nix { + linux = kernel; + }; + + kernels = lib.makeExtensible (self: with self; + let callPackage = newScope self; in { + + linux_mptcp_95 = callPackage ../os-specific/linux/kernel/linux-mptcp-95.nix { + kernelPatches = linux_4_19.kernelPatches; + }; + + linux_rpi1 = callPackage ../os-specific/linux/kernel/linux-rpi.nix { + kernelPatches = with kernelPatches; [ + bridge_stp_helper + request_key_helper + ]; + rpiVersion = 1; + }; + + linux_rpi2 = callPackage ../os-specific/linux/kernel/linux-rpi.nix { + kernelPatches = with kernelPatches; [ + bridge_stp_helper + request_key_helper + ]; + rpiVersion = 2; + }; + + linux_rpi3 = callPackage ../os-specific/linux/kernel/linux-rpi.nix { + kernelPatches = with kernelPatches; [ + bridge_stp_helper + request_key_helper + ]; + rpiVersion = 3; + }; + + linux_rpi4 = callPackage ../os-specific/linux/kernel/linux-rpi.nix { + kernelPatches = with kernelPatches; [ + bridge_stp_helper + request_key_helper + ]; + rpiVersion = 4; + }; + + linux_4_4 = callPackage ../os-specific/linux/kernel/linux-4.4.nix { + kernelPatches = + [ kernelPatches.bridge_stp_helper + kernelPatches.request_key_helper_updated + kernelPatches.cpu-cgroup-v2."4.4" + kernelPatches.modinst_arg_list_too_long + ]; + }; + + linux_4_9 = callPackage ../os-specific/linux/kernel/linux-4.9.nix { + kernelPatches = + [ kernelPatches.bridge_stp_helper + kernelPatches.request_key_helper_updated + kernelPatches.cpu-cgroup-v2."4.9" + kernelPatches.modinst_arg_list_too_long + ]; + }; + + linux_4_14 = callPackage ../os-specific/linux/kernel/linux-4.14.nix { + kernelPatches = + [ kernelPatches.bridge_stp_helper + kernelPatches.request_key_helper + # See pkgs/os-specific/linux/kernel/cpu-cgroup-v2-patches/README.md + # when adding a new linux version + kernelPatches.cpu-cgroup-v2."4.11" + kernelPatches.modinst_arg_list_too_long + ]; + }; + + linux_4_19 = callPackage ../os-specific/linux/kernel/linux-4.19.nix { + kernelPatches = + [ kernelPatches.bridge_stp_helper + kernelPatches.request_key_helper + kernelPatches.modinst_arg_list_too_long + ]; + }; + + linux_5_4 = callPackage ../os-specific/linux/kernel/linux-5.4.nix { + kernelPatches = [ + kernelPatches.bridge_stp_helper + kernelPatches.request_key_helper + kernelPatches.rtl8761b_support + ]; + }; + + linux_rt_5_4 = callPackage ../os-specific/linux/kernel/linux-rt-5.4.nix { + kernelPatches = [ + kernelPatches.bridge_stp_helper + kernelPatches.request_key_helper + ]; + }; + + linux_5_10 = callPackage ../os-specific/linux/kernel/linux-5.10.nix { + kernelPatches = [ + kernelPatches.bridge_stp_helper + kernelPatches.request_key_helper + ]; + }; + + linux_rt_5_10 = callPackage ../os-specific/linux/kernel/linux-rt-5.10.nix { + kernelPatches = [ + kernelPatches.bridge_stp_helper + kernelPatches.request_key_helper + kernelPatches.export-rt-sched-migrate + ]; + }; + + linux_rt_5_11 = callPackage ../os-specific/linux/kernel/linux-rt-5.11.nix { + kernelPatches = [ + kernelPatches.bridge_stp_helper + kernelPatches.request_key_helper + kernelPatches.export-rt-sched-migrate + ]; + }; + + linux_5_12 = callPackage ../os-specific/linux/kernel/linux-5.12.nix { + kernelPatches = [ + kernelPatches.bridge_stp_helper + kernelPatches.request_key_helper + ]; + }; + + linux_5_13 = callPackage ../os-specific/linux/kernel/linux-5.13.nix { + kernelPatches = [ + kernelPatches.bridge_stp_helper + kernelPatches.request_key_helper + ]; + }; + + linux_testing = callPackage ../os-specific/linux/kernel/linux-testing.nix { + kernelPatches = [ + kernelPatches.bridge_stp_helper + kernelPatches.request_key_helper + ]; + }; + + linux_testing_bcachefs = callPackage ../os-specific/linux/kernel/linux-testing-bcachefs.nix rec { + kernel = linux_5_13; + kernelPatches = kernel.kernelPatches; + }; + + linux_hardkernel_4_14 = callPackage ../os-specific/linux/kernel/linux-hardkernel-4.14.nix { + kernelPatches = [ + kernelPatches.bridge_stp_helper + kernelPatches.request_key_helper + kernelPatches.modinst_arg_list_too_long + ]; + }; + + linux_zen = callPackage ../os-specific/linux/kernel/linux-zen.nix { + kernelPatches = [ + kernelPatches.bridge_stp_helper + kernelPatches.request_key_helper + ]; + }; + + linux_lqx = callPackage ../os-specific/linux/kernel/linux-lqx.nix { + kernelPatches = [ + kernelPatches.bridge_stp_helper + kernelPatches.request_key_helper + ]; + }; + + linux_xanmod = callPackage ../os-specific/linux/kernel/linux-xanmod.nix { + kernelPatches = [ + kernelPatches.bridge_stp_helper + kernelPatches.request_key_helper + ]; + }; + + linux_libre = deblobKernel packageAliases.linux_default.kernel; + + linux_latest_libre = deblobKernel packageAliases.linux_latest.kernel; + + }); + /* Linux kernel modules are inherently tied to a specific kernel. So + rather than provide specific instances of those packages for a + specific kernel, we have a function that builds those packages + for a specific kernel. This function can then be called for + whatever kernel you're using. */ + + packagesFor = kernel_: lib.makeExtensible (self: with self; + let callPackage = newScope self; in { + inherit callPackage; + kernel = kernel_; + inherit (kernel) stdenv; # in particular, use the same compiler by default + + # to help determine module compatibility + inherit (kernel) isZen isHardened isLibre; + inherit (kernel) kernelOlder kernelAtLeast; + # Obsolete aliases (these packages do not depend on the kernel). + inherit (pkgs) odp-dpdk pktgen; # added 2018-05 + + acpi_call = callPackage ../os-specific/linux/acpi-call {}; + + akvcam = callPackage ../os-specific/linux/akvcam { + inherit (pkgs.qt5) qmake; + }; + + amdgpu-pro = callPackage ../os-specific/linux/amdgpu-pro { }; + + anbox = callPackage ../os-specific/linux/anbox/kmod.nix { }; + + apfs = callPackage ../os-specific/linux/apfs { }; + + batman_adv = callPackage ../os-specific/linux/batman-adv {}; + + bcc = callPackage ../os-specific/linux/bcc { + python = pkgs.python3; + }; + + bpftrace = callPackage ../os-specific/linux/bpftrace { }; + + bbswitch = callPackage ../os-specific/linux/bbswitch {}; + + chipsec = callPackage ../tools/security/chipsec { + inherit kernel; + withDriver = true; + }; + + cryptodev = callPackage ../os-specific/linux/cryptodev { }; + + cpupower = callPackage ../os-specific/linux/cpupower { }; + + ddcci-driver = callPackage ../os-specific/linux/ddcci { }; + + digimend = callPackage ../os-specific/linux/digimend { }; + + dpdk-kmods = callPackage ../os-specific/linux/dpdk-kmods { }; + + exfat-nofuse = callPackage ../os-specific/linux/exfat { }; + + evdi = callPackage ../os-specific/linux/evdi { }; + + fwts-efi-runtime = callPackage ../os-specific/linux/fwts/module.nix { }; + + gcadapter-oc-kmod = callPackage ../os-specific/linux/gcadapter-oc-kmod { }; + hid-nintendo = callPackage ../os-specific/linux/hid-nintendo { }; + + hyperv-daemons = callPackage ../os-specific/linux/hyperv-daemons { }; + + e1000e = if lib.versionOlder kernel.version "4.10" then callPackage ../os-specific/linux/e1000e {} else null; + + intel-speed-select = if lib.versionAtLeast kernel.version "5.3" then callPackage ../os-specific/linux/intel-speed-select { } else null; + + ixgbevf = callPackage ../os-specific/linux/ixgbevf {}; + + it87 = callPackage ../os-specific/linux/it87 {}; + + asus-wmi-sensors = callPackage ../os-specific/linux/asus-wmi-sensors {}; + + ena = callPackage ../os-specific/linux/ena {}; + + v4l2loopback = callPackage ../os-specific/linux/v4l2loopback { }; + + lttng-modules = callPackage ../os-specific/linux/lttng-modules { }; + + broadcom_sta = callPackage ../os-specific/linux/broadcom-sta { }; + + tbs = callPackage ../os-specific/linux/tbs { }; + + mbp2018-bridge-drv = callPackage ../os-specific/linux/mbp-modules/mbp2018-bridge-drv { }; + + nvidiabl = callPackage ../os-specific/linux/nvidiabl { }; + + nvidiaPackages = dontRecurseIntoAttrs (callPackage ../os-specific/linux/nvidia-x11 { }); + + nvidia_x11_legacy340 = nvidiaPackages.legacy_340; + nvidia_x11_legacy390 = nvidiaPackages.legacy_390; + nvidia_x11_beta = nvidiaPackages.beta; + nvidia_x11_vulkan_beta = nvidiaPackages.vulkan_beta; + nvidia_x11 = nvidiaPackages.stable; + + openrazer = callPackage ../os-specific/linux/openrazer/driver.nix { }; + + ply = callPackage ../os-specific/linux/ply { }; + + r8125 = callPackage ../os-specific/linux/r8125 { }; + + r8168 = callPackage ../os-specific/linux/r8168 { }; + + rtl8188eus-aircrack = callPackage ../os-specific/linux/rtl8188eus-aircrack { }; + + rtl8192eu = callPackage ../os-specific/linux/rtl8192eu { }; + + rtl8723bs = callPackage ../os-specific/linux/rtl8723bs { }; + + rtl8812au = callPackage ../os-specific/linux/rtl8812au { }; + + rtl8814au = callPackage ../os-specific/linux/rtl8814au { }; + + rtl88xxau-aircrack = callPackage ../os-specific/linux/rtl88xxau-aircrack {}; + + rtl8821au = callPackage ../os-specific/linux/rtl8821au { }; + + rtl8821ce = callPackage ../os-specific/linux/rtl8821ce { }; + + rtl88x2bu = callPackage ../os-specific/linux/rtl88x2bu { }; + + rtl8821cu = callPackage ../os-specific/linux/rtl8821cu { }; + + rtw88 = callPackage ../os-specific/linux/rtw88 { }; + rtlwifi_new = rtw88; + + rtw89 = callPackage ../os-specific/linux/rtw89 { }; + + openafs_1_8 = callPackage ../servers/openafs/1.8/module.nix { }; + openafs_1_9 = callPackage ../servers/openafs/1.9/module.nix { }; + # Current stable release; don't backport release updates! + openafs = openafs_1_8; + + facetimehd = callPackage ../os-specific/linux/facetimehd { }; + + tuxedo-keyboard = if lib.versionAtLeast kernel.version "4.14" then callPackage ../os-specific/linux/tuxedo-keyboard { } else null; + + jool = callPackage ../os-specific/linux/jool { }; + + kvmfr = callPackage ../os-specific/linux/kvmfr { }; + + mba6x_bl = callPackage ../os-specific/linux/mba6x_bl { }; + + mwprocapture = callPackage ../os-specific/linux/mwprocapture { }; + + mxu11x0 = callPackage ../os-specific/linux/mxu11x0 { }; + + # compiles but has to be integrated into the kernel somehow + # Let's have it uncommented and finish it.. + ndiswrapper = callPackage ../os-specific/linux/ndiswrapper { }; + + netatop = callPackage ../os-specific/linux/netatop { }; + + oci-seccomp-bpf-hook = if lib.versionAtLeast kernel.version "5.4" then callPackage ../os-specific/linux/oci-seccomp-bpf-hook { } else null; + + perf = if lib.versionAtLeast kernel.version "3.12" then callPackage ../os-specific/linux/kernel/perf.nix { } else null; + + phc-intel = if lib.versionAtLeast kernel.version "4.10" then callPackage ../os-specific/linux/phc-intel { } else null; + + # Disable for kernels 4.15 and above due to compatibility issues + prl-tools = if lib.versionOlder kernel.version "4.15" then callPackage ../os-specific/linux/prl-tools { } else null; + + sch_cake = callPackage ../os-specific/linux/sch_cake { }; + + isgx = callPackage ../os-specific/linux/isgx { }; + + sysdig = callPackage ../os-specific/linux/sysdig {}; + + systemtap = callPackage ../development/tools/profiling/systemtap { }; + + system76 = callPackage ../os-specific/linux/system76 { }; + + system76-acpi = callPackage ../os-specific/linux/system76-acpi { }; + + system76-power = callPackage ../os-specific/linux/system76-power { }; + + system76-io = callPackage ../os-specific/linux/system76-io { }; + + tmon = callPackage ../os-specific/linux/tmon { }; + + tp_smapi = callPackage ../os-specific/linux/tp_smapi { }; + + turbostat = callPackage ../os-specific/linux/turbostat { }; + + usbip = callPackage ../os-specific/linux/usbip { }; + + v86d = callPackage ../os-specific/linux/v86d { }; + + veikk-linux-driver = callPackage ../os-specific/linux/veikk-linux-driver { }; + vendor-reset = callPackage ../os-specific/linux/vendor-reset { }; + + vhba = callPackage ../misc/emulators/cdemu/vhba.nix { }; + + virtualbox = callPackage ../os-specific/linux/virtualbox { + virtualbox = pkgs.virtualboxHardened; + }; + + virtualboxGuestAdditions = callPackage ../applications/virtualization/virtualbox/guest-additions { + virtualbox = pkgs.virtualboxHardened; + }; + + wireguard = if lib.versionOlder kernel.version "5.6" then callPackage ../os-specific/linux/wireguard { } else null; + + x86_energy_perf_policy = callPackage ../os-specific/linux/x86_energy_perf_policy { }; + + xmm7360-pci = callPackage ../os-specific/linux/xmm7360-pci { }; + + xpadneo = callPackage ../os-specific/linux/xpadneo { }; + + zenpower = callPackage ../os-specific/linux/zenpower { }; + + inherit (callPackage ../os-specific/linux/zfs { + configFile = "kernel"; + inherit pkgs kernel; + }) zfsStable zfsUnstable; + zfs = zfsStable; + + can-isotp = callPackage ../os-specific/linux/can-isotp { }; + + } // lib.optionalAttrs (config.allowAliases or false) { + ati_drivers_x11 = throw "ati drivers are no longer supported by any kernel >=4.1"; # added 2021-05-18; + }); + + # Hardened Linux + hardenedPackagesFor = kernel': overrides: + let kernel = kernel'.override overrides; + in packagesFor (kernel.override { + structuredExtraConfig = import ../os-specific/linux/kernel/hardened/config.nix { + inherit lib; + inherit (kernel) version; + }; + kernelPatches = kernel.kernelPatches ++ [ + kernelPatches.hardened.${kernel.meta.branch} + ]; + modDirVersionArg = kernel.modDirVersion + (kernelPatches.hardened.${kernel.meta.branch}).extra; + isHardened = true; + }); + + vanillaPackages = { + # recurse to build modules for the kernels + linux_4_4 = recurseIntoAttrs (packagesFor kernels.linux_4_4); + linux_4_9 = recurseIntoAttrs (packagesFor kernels.linux_4_9); + linux_4_14 = recurseIntoAttrs (packagesFor kernels.linux_4_14); + linux_4_19 = recurseIntoAttrs (packagesFor kernels.linux_4_19); + linux_5_4 = recurseIntoAttrs (packagesFor kernels.linux_5_4); + linux_5_10 = recurseIntoAttrs (packagesFor kernels.linux_5_10); + linux_5_12 = recurseIntoAttrs (packagesFor kernels.linux_5_12); + linux_5_13 = recurseIntoAttrs (packagesFor kernels.linux_5_13); + }; + + rtPackages = { + # realtime kernel packages + linux_rt_5_4 = packagesFor kernels.linux_rt_5_4; + linux_rt_5_10 = packagesFor kernels.linux_rt_5_10; + linux_rt_5_11 = packagesFor kernels.linux_rt_5_11; + }; + + rpiPackages = { + linux_rpi1 = packagesFor kernels.linux_rpi1; + linux_rpi2 = packagesFor kernels.linux_rpi2; + linux_rpi3 = packagesFor kernels.linux_rpi3; + linux_rpi4 = packagesFor kernels.linux_rpi4; + }; + + packages = vanillaPackages // rtPackages // rpiPackages // { + linux_mptcp_95 = packagesFor kernels.linux_mptcp_95; + + # Intentionally lacks recurseIntoAttrs, as -rc kernels will quite likely break out-of-tree modules and cause failed Hydra builds. + linux_testing = packagesFor kernels.linux_testing; + linux_testing_bcachefs = recurseIntoAttrs (packagesFor kernels.linux_testing_bcachefs); + + linux_hardened = recurseIntoAttrs (hardenedPackagesFor packageAliases.linux_default.kernel { }); + # Note: We use an explicit version instead of linux_latest since the hardened patches + # can lag behind and we don't want to delay updates. + linux_latest_hardened = recurseIntoAttrs (hardenedPackagesFor kernels.linux_5_12 { }); + + linux_zen = recurseIntoAttrs (packagesFor kernels.linux_zen); + linux_lqx = recurseIntoAttrs (packagesFor kernels.linux_lqx); + linux_xanmod = recurseIntoAttrs (packagesFor kernels.linux_xanmod); + + hardkernel_4_14 = recurseIntoAttrs (packagesFor kernels.linux_hardkernel_4_14); + + linux_libre = recurseIntoAttrs (packagesFor kernels.linux_libre); + + linux_latest_libre = recurseIntoAttrs (packagesFor kernels.linux_latest_libre); + }; + + packageAliases = { + linux_default = packages.linux_5_10; + # Update this when adding the newest kernel major version! + linux_latest = packages.linux_5_13; + linux_mptcp = packages.linux_mptcp_95; + linux_rt_default = packages.linux_rt_5_4; + linux_rt_latest = packages.linux_rt_5_11; + linux_hardkernel_latest = packages.hardkernel_4_14; + }; + + manualConfig = makeOverridable (callPackage ../os-specific/linux/kernel/manual-config.nix {}); + +in + +{ + packages = recurseIntoAttrs packages; + kernels = recurseIntoAttrs kernels; + inherit packageAliases; + inherit vanillaPackages rtPackages rpiPackages; + inherit kernelPatches packagesFor hardenedPackagesFor; + + customPackage = { version, src, configfile, allowImportFromDerivation ? true }: + recurseIntoAttrs (packagesFor (manualConfig { + inherit version src configfile lib stdenv allowImportFromDerivation; + })); + + inherit manualConfig; + + # Derive one of the default .config files + linuxConfig = { + src, + version ? (builtins.parseDrvName src.name).version, + makeTarget ? "defconfig", + name ? "kernel.config", + }: stdenvNoCC.mkDerivation { + inherit name src; + depsBuildBuild = [ buildPackages.stdenv.cc ] + ++ lib.optionals (lib.versionAtLeast version "4.16") [ buildPackages.bison buildPackages.flex ]; + postPatch = '' + patchShebangs scripts/ + ''; + buildPhase = '' + set -x + make \ + ARCH=${stdenv.hostPlatform.linuxArch} \ + HOSTCC=${buildPackages.stdenv.cc.targetPrefix}gcc \ + ${makeTarget} + ''; + installPhase = '' + cp .config $out + ''; + }; + + buildLinux = attrs: callPackage ../os-specific/linux/kernel/generic.nix attrs; + +} +