@ -1,3 +1,11 @@
{ buildPackages , runCommand , nettools , bc , perl , gmp , libmpc , mpfr , openssl
, ncurses
, libelf
, utillinux
, writeTextFile , ubootTools
, callPackage
} :
{ stdenv , buildPackages , perl , buildLinux
, # The kernel source tarball.
@ -28,7 +36,7 @@
, extraMeta ? { }
, hostPlatform
, . . .
} :
} @ args :
assert stdenv . isLinux ;
@ -45,8 +53,10 @@ let
} // features ) kernelPatches ;
config = import ./common-config.nix {
inherit stdenv version extraConfig ;
kernelPlatform = hostPlatform ;
inherit stdenv version ;
# append extraConfig for backwards compatibility but also means the user can't override the kernelExtraConfig part
extraConfig = extraConfig + lib . optionalString ( hostPlatform ? kernelExtraConfig ) hostPlatform . kernelExtraConfig ;
features = kernelFeatures ; # Ensure we know of all extra patches, etc.
} ;
@ -68,7 +78,9 @@ let
nativeBuildInputs = [ perl ] ;
platformName = hostPlatform . platform . name ;
# e.g. "defconfig"
kernelBaseConfig = hostPlatform . platform . kernelBaseConfig ;
# e.g. "bzImage"
kernelTarget = hostPlatform . platform . kernelTarget ;
autoModules = hostPlatform . platform . kernelAutoModules ;
preferBuiltin = hostPlatform . platform . kernelPreferBuiltin or false ;
@ -83,25 +95,25 @@ let
inherit ( kernel ) src patches preUnpack ;
buildPhase = ''
cd $ buildRoot
export buildRoot = " ' ' ${ buildRoot:-build } "
# Get a basic config file for later refinement with $generateConfig.
make HOSTCC = $ { buildPackages . stdenv . cc . targetPrefix } gcc - C . . / $ sourceRoot O = $ PWD $ kernelBaseConfig ARCH = $ arch
make HOSTCC = $ { buildPackages . stdenv . cc . targetPrefix } gcc - C . O = " $ b u i l d R o o t " $ kernelBaseConfig ARCH = $ arch
# Create the config file.
echo " g e n e r a t i n g k e r n e l c o n f i g u r a t i o n . . . "
echo " $ k e r n e l C o n f i g " > kern el -c on fig
DEBUG = 1 ARCH = $ arch KERNEL_CONFIG = kern el -c on fig AUTO_MODULES = $ autoModules \
PREFER_BUILTIN = $ preferBuiltin SRC = . . / $ sourceRoot perl - w $ generateConfig
echo " $ k e r n e l C o n f i g " > " $ b u i l d R o o t / k e rn el -c on f i g"
DEBUG = 1 ARCH = $ arch KERNEL_CONFIG = " $ b u i l d R o o t / k e rn el -c on f i g" AUTO_MODULES = $ autoModules \
PREFER_BUILTIN = $ preferBuiltin BUILD_ROOT = " $ b u i l d R o o t " SRC = . perl - w $ generateConfig
'' ;
installPhase = " m v . c o n f i g $ o u t " ;
installPhase = " m v $ b u i l d R o o t / .c o n f i g $ o u t " ;
enableParallelBuilding = true ;
} ;
kernel = buildLinux {
inherit version modDirVersion src kernelPatches stdenv extraMeta configfile ;
kernel = ( callPackage ./manual-config.nix { } ) {
inherit version modDirVersion src kernelPatches stdenv extraMeta configfile hostPlatform ;
config = { CONFIG_MODULES = " y " ; CONFIG_FW_LOADER = " m " ; } ;
} ;