diff options
author | Matthieu Coudron <mattator@gmail.com> | 2018-10-03 18:49:50 +0900 |
---|---|---|
committer | Matthieu Coudron <mattator@gmail.com> | 2019-01-28 09:06:33 +0900 |
commit | 3bb7b3f02e884db944a8a20b4f19227482479b94 (patch) | |
tree | 5a42d2657691b88360fcb8188b34010dfdd75e15 /pkgs/os-specific/linux/kernel/generic.nix | |
parent | bf041c3f1d5e63e27b531faf69244fe99fcfd6c1 (diff) | |
download | nixpkgs-3bb7b3f02e884db944a8a20b4f19227482479b94.tar nixpkgs-3bb7b3f02e884db944a8a20b4f19227482479b94.tar.gz nixpkgs-3bb7b3f02e884db944a8a20b4f19227482479b94.tar.bz2 nixpkgs-3bb7b3f02e884db944a8a20b4f19227482479b94.tar.lz nixpkgs-3bb7b3f02e884db944a8a20b4f19227482479b94.tar.xz nixpkgs-3bb7b3f02e884db944a8a20b4f19227482479b94.tar.zst nixpkgs-3bb7b3f02e884db944a8a20b4f19227482479b94.zip |
linux: ability to merge structured configs
This should make the composability of kernel configurations more straigthforward. - now distinguish freeform options from tristate ones - will look for a structured config in kernelPatches too one can now access the structuredConfig from a kernel via linux_test.configfile.structuredConfig in order to reinject it into another kernel, no need to rewrite the config from scratch The following merge strategies are used in case of conflict: -- freeform items must be equal or they conflict (mergeEqualOption) -- for tristate (y/m/n) entries, I use the mergeAnswer strategy which takes the best available value, "best" being defined by the user (by default "y" > "m" > "n", e.g. if one entry is both marked "y" and "n", "y" wins) -- if one item is both marked optional/mandatory, mandatory wins (mergeFalseByDefault)
Diffstat (limited to 'pkgs/os-specific/linux/kernel/generic.nix')
-rw-r--r-- | pkgs/os-specific/linux/kernel/generic.nix | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix index 30878d1b96c..a41f1eb989b 100644 --- a/pkgs/os-specific/linux/kernel/generic.nix +++ b/pkgs/os-specific/linux/kernel/generic.nix @@ -47,7 +47,6 @@ , preferBuiltin ? stdenv.hostPlatform.platform.kernelPreferBuiltin or false , kernelArch ? stdenv.hostPlatform.platform.kernelArch -, mkValueOverride ? null , ... }: @@ -68,20 +67,26 @@ let ia32Emulation = true; } // features) kernelPatches; - 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 (stdenv.hostPlatform.platform ? kernelExtraConfig) stdenv.hostPlatform.platform.kernelExtraConfig; + commonStructuredConfig = import ./common-config.nix { + inherit stdenv version ; features = kernelFeatures; # Ensure we know of all extra patches, etc. }; - kernelConfigFun = baseConfig: + # extra config in legacy string format + extraConfig = extraConfig + lib.optionalString (stdenv.hostPlatform.platform ? kernelExtraConfig) stdenv.hostPlatform.platform.kernelExtraConfig; + + intermediateNixConfig = configfile.moduleStructuredConfig.intermediateNixConfig; + + structuredConfigFromPatches = + map ({extraStructuredConfig ? {}, ...}: {settings=extraStructuredConfig;}) kernelPatches; + + # appends kernel patches extraConfig + kernelConfigFun = baseConfigStr: let configFromPatches = map ({extraConfig ? "", ...}: extraConfig) kernelPatches; - in lib.concatStringsSep "\n" ([baseConfig] ++ configFromPatches); + in lib.concatStringsSep "\n" ([baseConfigStr] ++ configFromPatches); configfile = stdenv.mkDerivation { inherit ignoreConfigErrors autoModules preferBuiltin kernelArch; @@ -131,7 +136,30 @@ let installPhase = "mv $buildRoot/.config $out"; enableParallelBuilding = true; - }; + + passthru = rec { + + module = import ../../../../nixos/modules/system/boot/kernel_config.nix; + # used also in apache + # { modules = [ { options = res.options; config = svc.config or svc; } ]; + # check = false; + # The result is a set of two attributes + moduleStructuredConfig = (lib.evalModules { + modules = [ + module + { settings = commonStructuredConfig; } + { settings = structuredExtraConfig; } + ] + ++ structuredConfigFromPatches + ; + }).config; + + # + structuredConfig = moduleStructuredConfig.settings; + }; + + + }; # end of configfile derivation kernel = (callPackage ./manual-config.nix {}) { inherit version modDirVersion src kernelPatches stdenv extraMeta configfile; @@ -141,6 +169,7 @@ let passthru = { features = kernelFeatures; + inherit commonStructuredConfig; passthru = kernel.passthru // (removeAttrs passthru [ "passthru" ]); }; |