-
-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
trying to be more flexible about config generation suing functions/sh…
…ell etc wip in pkgs/os-specific/linux/kernel/config.nix
- Loading branch information
Showing
3 changed files
with
142 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# {stdenv | ||
# , buildRoot | ||
# , srcRoot | ||
# }: | ||
{ | ||
patchKconfig = '' | ||
# Patch kconfig to print "###" after every question so that | ||
# generate-config.pl from the generic builder can answer them. | ||
sed -e '/fflush(stdout);/i\printf("###");' -i scripts/kconfig/conf.c | ||
''; | ||
|
||
|
||
# | ||
buildKernelConfig = arch: autoModules: '' | ||
cd $buildRoot | ||
# Get a basic config file for later refinement with $generateConfig. | ||
make -C ../$sourceRoot O=$PWD $kernelBaseConfig ARCH=$arch | ||
# Create the config file. | ||
echo "generating kernel configuration..." | ||
echo "$kernelConfig" > kernel-config | ||
DEBUG=1 ARCH=$arch KERNEL_CONFIG=kernel-config AUTO_MODULES=$autoModules \ | ||
PREFER_BUILTIN=$preferBuiltin SRC=../$sourceRoot perl -w $generateConfig | ||
''; | ||
|
||
} | ||
# TODO we should be able to generate standalone config and config on the go | ||
# => we need functions with module etc | ||
# espcially we need a bash builder | ||
# TODO have a standalone | ||
stdenv.mkDerivation { | ||
inherit ignoreConfigErrors; | ||
name = "linux-config-${version}"; | ||
|
||
generateConfig = ./generate-config.pl; | ||
|
||
kernelConfig = kernelConfigFun config; | ||
|
||
nativeBuildInputs = [ perl ]; | ||
|
||
platformName = stdenv.platform.name; | ||
kernelBaseConfig = stdenv.platform.kernelBaseConfig; | ||
kernelTarget = stdenv.platform.kernelTarget; | ||
autoModules = stdenv.platform.kernelAutoModules; | ||
preferBuiltin = stdenv.platform.kernelPreferBuiltin or false; | ||
arch = stdenv.platform.kernelArch; | ||
|
||
crossAttrs = let | ||
cp = hostPlatform.platform; | ||
in { | ||
arch = cp.kernelArch; | ||
platformName = cp.name; | ||
kernelBaseConfig = cp.kernelBaseConfig; | ||
kernelTarget = cp.kernelTarget; | ||
autoModules = cp.kernelAutoModules; | ||
|
||
# Just ignore all options that don't apply (We are lazy). | ||
ignoreConfigErrors = true; | ||
|
||
kernelConfig = kernelConfigFun configCross; | ||
|
||
inherit (kernel.crossDrv) src patches preUnpack; | ||
}; | ||
|
||
prePatch = kernel.prePatch + patchKconfig; | ||
inherit (kernel) src patches preUnpack; | ||
|
||
buildPhase = '' | ||
cd $buildRoot | ||
# Get a basic config file for later refinement with $generateConfig. | ||
make -C ../$sourceRoot O=$PWD $kernelBaseConfig ARCH=$arch | ||
# Create the config file. | ||
echo "generating kernel configuration..." | ||
echo "$kernelConfig" > kernel-config | ||
DEBUG=1 ARCH=$arch KERNEL_CONFIG=kernel-config AUTO_MODULES=$autoModules \ | ||
PREFER_BUILTIN=$preferBuiltin SRC=../$sourceRoot perl -w $generateConfig | ||
''; | ||
|
||
installPhase = "mv .config $out"; | ||
|
||
enableParallelBuilding = true; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters