summary refs log tree commit diff
path: root/pkgs/os-specific/linux/kernel/generic.nix
diff options
context:
space:
mode:
authorDan Peebles <pumpkin@me.com>2016-01-05 09:22:43 -0500
committerTuomas Tynkkynen <tuomas@tuxera.com>2018-06-30 16:01:41 +0300
commitff9999ad1b19b941b275b7ec79514d04c7cdad7d (patch)
treee3167d9f1a1483d51c756cb1990bdaab76a58a2d /pkgs/os-specific/linux/kernel/generic.nix
parentbae87d504224d853c5548d2aa244b596569fc7f3 (diff)
downloadnixpkgs-ff9999ad1b19b941b275b7ec79514d04c7cdad7d.tar
nixpkgs-ff9999ad1b19b941b275b7ec79514d04c7cdad7d.tar.gz
nixpkgs-ff9999ad1b19b941b275b7ec79514d04c7cdad7d.tar.bz2
nixpkgs-ff9999ad1b19b941b275b7ec79514d04c7cdad7d.tar.lz
nixpkgs-ff9999ad1b19b941b275b7ec79514d04c7cdad7d.tar.xz
nixpkgs-ff9999ad1b19b941b275b7ec79514d04c7cdad7d.tar.zst
nixpkgs-ff9999ad1b19b941b275b7ec79514d04c7cdad7d.zip
linux: translate config to structured config
Instead of using a string to describe kernel config, use a nix
attribute set, then converted to a string.
- allows to override the config, aka convert 'yes' into 'modules' or
vice-versa
- while for now merging different configs is still crude (last spec wins),
at least there should be only one CONFIG_XYZ value compared to the current string
config where the first defined would be used and others ignored.

[initial idea by copumpkin in 2016, a major rebase to 2018 by teto]
Diffstat (limited to 'pkgs/os-specific/linux/kernel/generic.nix')
-rw-r--r--pkgs/os-specific/linux/kernel/generic.nix13
1 files changed, 9 insertions, 4 deletions
diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix
index 249a1ea5cef..fde6efd797d 100644
--- a/pkgs/os-specific/linux/kernel/generic.nix
+++ b/pkgs/os-specific/linux/kernel/generic.nix
@@ -15,9 +15,12 @@
 , # Allows overriding the default defconfig
   defconfig ? null
 
-, # Overrides to the kernel config.
+, # Legacy overrides to the intermediate kernel config, as string
   extraConfig ? ""
 
+, # kernel intermediate config overrides, as a set
+ structuredExtraConfig ? {}
+
 , # The version number used for the module directory
   modDirVersion ? version
 
@@ -42,6 +45,7 @@
 , preferBuiltin ? hostPlatform.platform.kernelPreferBuiltin or false
 , kernelArch ? hostPlatform.platform.kernelArch
 
+, mkValueOverride ? null
 , ...
 } @ args:
 
@@ -59,8 +63,9 @@ let
     netfilterRPFilter = true;
   } // features) kernelPatches;
 
-  config = import ./common-config.nix {
-    inherit stdenv version ;
+  intermediateNixConfig = import ./common-config.nix {
+    inherit stdenv version structuredExtraConfig mkValueOverride;
+
     # append extraConfig for backwards compatibility but also means the user can't override the kernelExtraConfig part
     extraConfig = extraConfig + lib.optionalString (hostPlatform.platform ? kernelExtraConfig) hostPlatform.platform.kernelExtraConfig;
 
@@ -79,7 +84,7 @@ let
 
     generateConfig = ./generate-config.pl;
 
-    kernelConfig = kernelConfigFun config;
+    kernelConfig = kernelConfigFun intermediateNixConfig;
     passAsFile = [ "kernelConfig" ];
 
     depsBuildBuild = [ buildPackages.stdenv.cc ];