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]
This commit is contained in:
Dan Peebles
2016-01-05 09:22:43 -05:00
committed by Tuomas Tynkkynen
parent bae87d5042
commit ff9999ad1b
4 changed files with 739 additions and 697 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -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 ];

View File

@@ -24,7 +24,7 @@ in {
modDirVersion ? version,
# The kernel source (tarball, git checkout, etc.)
src,
# Any patches
# a list of { name=..., patch=..., extraConfig=...} patches
kernelPatches ? [],
# The kernel .config file
configfile,