diff options
-rw-r--r-- | lib/default.nix | 3 | ||||
-rw-r--r-- | lib/kernel.nix | 17 | ||||
-rw-r--r-- | pkgs/os-specific/linux/kernel/common-config.nix | 5 | ||||
-rw-r--r-- | pkgs/os-specific/linux/kernel/hardened-config.nix | 3 | ||||
-rw-r--r-- | pkgs/os-specific/linux/kernel/mptcp-config.nix | 2 |
5 files changed, 20 insertions, 10 deletions
diff --git a/lib/default.nix b/lib/default.nix index 4971e68ebd3a4..a909cefd60f1e 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -56,6 +56,9 @@ let # back-compat aliases platforms = systems.doubles; + # linux kernel configuration + kernel = callLibs ./kernel.nix; + inherit (builtins) add addErrorContext attrNames concatLists deepSeq elem elemAt filter genericClosure genList getAttr hasAttr head isAttrs isBool isInt isList isString length diff --git a/lib/kernel.nix b/lib/kernel.nix index 36ea308382893..2ce19f8cb68c0 100644 --- a/lib/kernel.nix +++ b/lib/kernel.nix @@ -1,12 +1,7 @@ -{ lib, version }: +{ lib }: with lib; { - # Common patterns/legacy - whenAtLeast = ver: mkIf (versionAtLeast version ver); - whenOlder = ver: mkIf (versionOlder version ver); - # range is (inclusive, exclusive) - whenBetween = verLow: verHigh: mkIf (versionAtLeast version verLow && versionOlder version verHigh); # Keeping these around in case we decide to change this horrible implementation :) @@ -18,4 +13,14 @@ with lib; module = { tristate = "m"; }; freeform = x: { freeform = x; }; + /* + Common patterns/legacy used in common-config/hardened-config.nix + */ + whenHelpers = version: { + whenAtLeast = ver: mkIf (versionAtLeast version ver); + whenOlder = ver: mkIf (versionOlder version ver); + # range is (inclusive, exclusive) + whenBetween = verLow: verHigh: mkIf (versionAtLeast version verLow && versionOlder version verHigh); + }; + } diff --git a/pkgs/os-specific/linux/kernel/common-config.nix b/pkgs/os-specific/linux/kernel/common-config.nix index e925068421d68..2c8b8de65b319 100644 --- a/pkgs/os-specific/linux/kernel/common-config.nix +++ b/pkgs/os-specific/linux/kernel/common-config.nix @@ -16,11 +16,12 @@ }: with stdenv.lib; - - with import ../../../../lib/kernel.nix { inherit (stdenv) lib; inherit version; }; +with stdenv.lib.kernel; +with (stdenv.lib.kernel.whenHelpers version); let + # configuration items have to be part of a subattrs flattenKConf = nested: mapAttrs (_: head) (zipAttrs (attrValues nested)); diff --git a/pkgs/os-specific/linux/kernel/hardened-config.nix b/pkgs/os-specific/linux/kernel/hardened-config.nix index 156a4cf44234b..b28ce770f7a9e 100644 --- a/pkgs/os-specific/linux/kernel/hardened-config.nix +++ b/pkgs/os-specific/linux/kernel/hardened-config.nix @@ -11,7 +11,8 @@ { stdenv, version }: with stdenv.lib; -with import ../../../../lib/kernel.nix { inherit (stdenv) lib; inherit version; }; +with stdenv.lib.kernel; +with (stdenv.lib.kernel.whenHelpers version); assert (versionAtLeast version "4.9"); diff --git a/pkgs/os-specific/linux/kernel/mptcp-config.nix b/pkgs/os-specific/linux/kernel/mptcp-config.nix index e5e3ee283fff6..9752e63d9f944 100644 --- a/pkgs/os-specific/linux/kernel/mptcp-config.nix +++ b/pkgs/os-specific/linux/kernel/mptcp-config.nix @@ -1,5 +1,5 @@ { stdenv }: -with import ../../../../lib/kernel.nix { inherit (stdenv) lib; version = null; }; +with stdenv.lib.kernel; { # DRM_AMDGPU = yes; |