summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthieu Coudron <mattator@gmail.com>2019-09-18 17:34:02 +0900
committerMatthieu Coudron <mattator@gmail.com>2019-10-01 15:57:14 +0900
commitafa0e02d64b15707262f13a348b33dad735bd80f (patch)
tree55d7b968cd62ee20069cb935f7fc9f3567629a77
parent2436c27541b2f52deea3a4c1691216a02152e729 (diff)
downloadnixpkgs-afa0e02d64b15707262f13a348b33dad735bd80f.tar
nixpkgs-afa0e02d64b15707262f13a348b33dad735bd80f.tar.gz
nixpkgs-afa0e02d64b15707262f13a348b33dad735bd80f.tar.bz2
nixpkgs-afa0e02d64b15707262f13a348b33dad735bd80f.tar.lz
nixpkgs-afa0e02d64b15707262f13a348b33dad735bd80f.tar.xz
nixpkgs-afa0e02d64b15707262f13a348b33dad735bd80f.tar.zst
nixpkgs-afa0e02d64b15707262f13a348b33dad735bd80f.zip
lib.kernel: make public
Remove the "version" parameter in order to make it more widely
available.
Starts making some kernel configuration helpers available.
The intent is to be able to better build and check the linux kernel
configuration.
-rw-r--r--lib/default.nix3
-rw-r--r--lib/kernel.nix7
-rw-r--r--pkgs/os-specific/linux/kernel/common-config.nix9
-rw-r--r--pkgs/os-specific/linux/kernel/hardened-config.nix3
-rw-r--r--pkgs/os-specific/linux/kernel/mptcp-config.nix2
5 files changed, 13 insertions, 11 deletions
diff --git a/lib/default.nix b/lib/default.nix
index 18d2dfae1e1..efa47a67f96 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -52,6 +52,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 36ea3083828..bfadf148be2 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 :)
diff --git a/pkgs/os-specific/linux/kernel/common-config.nix b/pkgs/os-specific/linux/kernel/common-config.nix
index 3b409f15aba..d414a084262 100644
--- a/pkgs/os-specific/linux/kernel/common-config.nix
+++ b/pkgs/os-specific/linux/kernel/common-config.nix
@@ -16,10 +16,15 @@
 }:
 
 with stdenv.lib;
-
-  with import ../../../../lib/kernel.nix { inherit (stdenv) lib; inherit version; };
+with stdenv.lib.kernel;
 
 let
+  # 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);
+
 
   # 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 156a4cf4423..b72994d6dd6 100644
--- a/pkgs/os-specific/linux/kernel/hardened-config.nix
+++ b/pkgs/os-specific/linux/kernel/hardened-config.nix
@@ -11,8 +11,7 @@
 { stdenv, version }:
 
 with stdenv.lib;
-with import ../../../../lib/kernel.nix { inherit (stdenv) lib; inherit version; };
-
+with stdenv.lib.kernel;
 assert (versionAtLeast version "4.9");
 
 optionalAttrs (stdenv.hostPlatform.platform.kernelArch == "x86_64") {
diff --git a/pkgs/os-specific/linux/kernel/mptcp-config.nix b/pkgs/os-specific/linux/kernel/mptcp-config.nix
index e5e3ee283ff..9752e63d9f9 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;