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:
parent
9ce4e47bf6
commit
da36847d92
@ -53,6 +53,27 @@ rec {
|
||||
# argument, but it's nice this way if several uses of `extends` are cascaded.
|
||||
extends = f: rattrs: self: let super = rattrs self; in super // f self super;
|
||||
|
||||
# Create an overridable, recursive attribute set. For example:
|
||||
#
|
||||
# nix-repl> obj = makeExtensible (self: { })
|
||||
#
|
||||
# nix-repl> obj
|
||||
# { __unfix__ = «lambda»; extend = «lambda»; }
|
||||
#
|
||||
# nix-repl> obj = obj.extend (self: super: { foo = "foo"; })
|
||||
#
|
||||
# nix-repl> obj
|
||||
# { __unfix__ = «lambda»; extend = «lambda»; foo = "foo"; }
|
||||
#
|
||||
# nix-repl> obj = obj.extend (self: super: { foo = super.foo + " + "; bar = "bar"; foobar = self.foo + self.bar; })
|
||||
#
|
||||
# nix-repl> obj
|
||||
# { __unfix__ = «lambda»; bar = "bar"; extend = «lambda»; foo = "foo + "; foobar = "foo + bar"; }
|
||||
makeExtensible = rattrs:
|
||||
fix' rattrs // {
|
||||
extend = f: makeExtensible (extends f rattrs);
|
||||
};
|
||||
|
||||
# Flip the order of the arguments of a binary function.
|
||||
flip = f: a: b: f b a;
|
||||
|
||||
|
@ -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 = [ ];
|
||||
|
@ -10873,7 +10873,9 @@ in
|
||||
for a specific kernel. This function can then be called for
|
||||
whatever kernel you're using. */
|
||||
|
||||
linuxPackagesFor = kernel: self: let callPackage = newScope self; in rec {
|
||||
linuxPackagesFor = kernel: lib.makeExtensible (self: with self; {
|
||||
callPackage = newScope self;
|
||||
|
||||
inherit kernel;
|
||||
|
||||
accelio = callPackage ../development/libraries/accelio { };
|
||||
@ -10991,7 +10993,7 @@ in
|
||||
configFile = "kernel";
|
||||
inherit kernel spl;
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
# The current default kernel / kernel modules.
|
||||
linuxPackages = linuxPackages_4_4;
|
||||
@ -11002,29 +11004,27 @@ in
|
||||
linux_latest = linuxPackages_latest.kernel;
|
||||
|
||||
# Build the kernel modules for the some of the kernels.
|
||||
linuxPackages_mptcp = linuxPackagesFor pkgs.linux_mptcp linuxPackages_mptcp;
|
||||
linuxPackages_rpi = linuxPackagesFor pkgs.linux_rpi linuxPackages_rpi;
|
||||
linuxPackages_3_10 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_3_10 linuxPackages_3_10);
|
||||
linuxPackages_3_10_tuxonice = linuxPackagesFor pkgs.linux_3_10_tuxonice linuxPackages_3_10_tuxonice;
|
||||
linuxPackages_3_12 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_3_12 linuxPackages_3_12);
|
||||
linuxPackages_3_18 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_3_18 linuxPackages_3_18);
|
||||
linuxPackages_4_1 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_4_1 linuxPackages_4_1);
|
||||
linuxPackages_4_4 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_4_4 linuxPackages_4_4);
|
||||
linuxPackages_4_7 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_4_7 linuxPackages_4_7);
|
||||
linuxPackages_4_8 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_4_8 linuxPackages_4_8);
|
||||
linuxPackages_mptcp = linuxPackagesFor pkgs.linux_mptcp;
|
||||
linuxPackages_rpi = linuxPackagesFor pkgs.linux_rpi;
|
||||
linuxPackages_3_10 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_3_10);
|
||||
linuxPackages_3_10_tuxonice = linuxPackagesFor pkgs.linux_3_10_tuxonice;
|
||||
linuxPackages_3_12 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_3_12);
|
||||
linuxPackages_3_18 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_3_18);
|
||||
linuxPackages_4_1 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_4_1);
|
||||
linuxPackages_4_4 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_4_4);
|
||||
linuxPackages_4_7 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_4_7);
|
||||
linuxPackages_4_8 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_4_8);
|
||||
# Don't forget to update linuxPackages_latest!
|
||||
|
||||
# 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_testing;
|
||||
linuxPackages_testing = linuxPackagesFor pkgs.linux_testing;
|
||||
|
||||
linuxPackages_custom = {version, src, configfile}:
|
||||
let linuxPackages_self = (linuxPackagesFor (pkgs.linuxManualConfig {inherit version src configfile;
|
||||
allowImportFromDerivation=true;})
|
||||
linuxPackages_self);
|
||||
in recurseIntoAttrs linuxPackages_self;
|
||||
recurseIntoAttrs (linuxPackagesFor (pkgs.linuxManualConfig {inherit version src configfile;
|
||||
allowImportFromDerivation=true;}));
|
||||
|
||||
# Build a kernel for Xen dom0
|
||||
linuxPackages_latest_xen_dom0 = recurseIntoAttrs (linuxPackagesFor (pkgs.linux_latest.override { features.xen_dom0=true; }) linuxPackages_latest);
|
||||
linuxPackages_latest_xen_dom0 = recurseIntoAttrs (linuxPackagesFor (pkgs.linux_latest.override { features.xen_dom0=true; }));
|
||||
|
||||
# Grsecurity packages
|
||||
|
||||
@ -11044,8 +11044,7 @@ in
|
||||
};
|
||||
|
||||
linuxPackages_grsec_nixos =
|
||||
let self = linuxPackagesFor linux_grsec_nixos self;
|
||||
in recurseIntoAttrs self;
|
||||
recurseIntoAttrs (linuxPackagesFor linux_grsec_nixos);
|
||||
|
||||
# An unsupported grsec xen guest kernel
|
||||
linux_grsec_server_xen = linux_grsec_nixos.override {
|
||||
@ -11059,9 +11058,9 @@ in
|
||||
};
|
||||
|
||||
# ChromiumOS kernels
|
||||
linuxPackages_chromiumos_3_14 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_chromiumos_3_14 linuxPackages_chromiumos_3_14);
|
||||
linuxPackages_chromiumos_3_18 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_chromiumos_3_18 linuxPackages_chromiumos_3_18);
|
||||
linuxPackages_chromiumos_latest = recurseIntoAttrs (linuxPackagesFor pkgs.linux_chromiumos_latest linuxPackages_chromiumos_latest);
|
||||
linuxPackages_chromiumos_3_14 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_chromiumos_3_14);
|
||||
linuxPackages_chromiumos_3_18 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_chromiumos_3_18);
|
||||
linuxPackages_chromiumos_latest = recurseIntoAttrs (linuxPackagesFor pkgs.linux_chromiumos_latest);
|
||||
|
||||
# A function to build a manually-configured kernel
|
||||
linuxManualConfig = pkgs.buildLinux;
|
||||
|
Loading…
Reference in New Issue
Block a user