kernel: buildLinux replaces import ./generic.nix
- defined buildLinux as generic.nix instead of manual-config.nix. This makes kernel derivations a tad more similar to your typical derivations. - moved $buildRoot to within the source folder, this way it doesn't have to be created before the unpackPhase and make it easier to work on kernel source without running the unpackPhase
This commit is contained in:
@@ -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="$buildRoot" $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
|
||||
echo "$kernelConfig" > "$buildRoot/kernel-config"
|
||||
DEBUG=1 ARCH=$arch KERNEL_CONFIG="$buildRoot/kernel-config" AUTO_MODULES=$autoModules \
|
||||
PREFER_BUILTIN=$preferBuiltin BUILD_ROOT="$buildRoot" SRC=. perl -w $generateConfig
|
||||
'';
|
||||
|
||||
installPhase = "mv .config $out";
|
||||
installPhase = "mv $buildRoot/.config $out";
|
||||
|
||||
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"; };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user