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
This commit is contained in:
Charles Strahan
2016-10-11 19:59:00 -04:00
parent 9ce4e47bf6
commit da36847d92
3 changed files with 58 additions and 24 deletions
+15 -1
View File
@@ -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 = [ ];