about summary refs log tree commit diff
path: root/nixos/modules/system/boot
diff options
context:
space:
mode:
authorCharles Strahan <charles@cstrahan.com>2016-04-30 00:19:57 -0400
committerCharles Strahan <charles@cstrahan.com>2016-10-11 19:59:00 -0400
commitda36847d925058fd86f027b64cc712c57be11ad8 (patch)
tree232dd7e5aa3188fc587392a0bbc180d3e3b44e0b /nixos/modules/system/boot
parent9ce4e47bf6acccbb586c8caaf6f2bcf20789ac39 (diff)
downloadnixlib-da36847d925058fd86f027b64cc712c57be11ad8.tar
nixlib-da36847d925058fd86f027b64cc712c57be11ad8.tar.gz
nixlib-da36847d925058fd86f027b64cc712c57be11ad8.tar.bz2
nixlib-da36847d925058fd86f027b64cc712c57be11ad8.tar.lz
nixlib-da36847d925058fd86f027b64cc712c57be11ad8.tar.xz
nixlib-da36847d925058fd86f027b64cc712c57be11ad8.tar.zst
nixlib-da36847d925058fd86f027b64cc712c57be11ad8.zip
nixos: make it easy to apply kernel patches
This makes it easy to specify kernel patches:

    boot.kernelPatches = [ pkgs.kernelPatches.ubuntu_fan_4_4 ];

To make the `boot.kernelPatches` option possible, this also makes it
easy to extend and/or modify the kernel packages within a linuxPackages
set. For example:

    pkgs.linuxPackages.extend (self: super: {
      kernel = super.kernel.override {
        kernelPatches = super.kernel.kernelPatches ++ [
          pkgs.kernelPatches.ubuntu_fan_4_4
        ];
      };
    });

Closes #15095
Diffstat (limited to 'nixos/modules/system/boot')
-rw-r--r--nixos/modules/system/boot/kernel.nix16
1 files changed, 15 insertions, 1 deletions
diff --git a/nixos/modules/system/boot/kernel.nix b/nixos/modules/system/boot/kernel.nix
index ba15d0318b17..51b3b8a3dca9 100644
--- a/nixos/modules/system/boot/kernel.nix
+++ b/nixos/modules/system/boot/kernel.nix
@@ -4,7 +4,9 @@ with lib;
 
 let
 
-  kernel = config.boot.kernelPackages.kernel;
+  inherit (config.boot) kernelPatches;
+
+  inherit (config.boot.kernelPackages) kernel;
 
   kernelModulesConf = pkgs.writeText "nixos.conf"
     ''
@@ -21,6 +23,11 @@ in
 
     boot.kernelPackages = mkOption {
       default = pkgs.linuxPackages;
+      apply = kernelPackages: kernelPackages.extend (self: super: {
+        kernel = super.kernel.override {
+          kernelPatches = super.kernel.kernelPatches ++ kernelPatches;
+        };
+      });
       # We don't want to evaluate all of linuxPackages for the manual
       # - some of it might not even evaluate correctly.
       defaultText = "pkgs.linuxPackages";
@@ -39,6 +46,13 @@ in
       '';
     };
 
+    boot.kernelPatches = mkOption {
+      type = types.listOf types.attrs;
+      default = [];
+      example = literalExample "[ pkgs.kernelPatches.ubuntu_fan_4_4 ]";
+      description = "A list of additional patches to apply to the kernel.";
+    };
+
     boot.kernelParams = mkOption {
       type = types.listOf types.str;
       default = [ ];