-
-
Notifications
You must be signed in to change notification settings - Fork 13.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RDY] buildLinux: Add more overrides #34351
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @teto great change, I didn't even notice this before :). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean moving kernelExtraConfig from platforms.* to the buildLinux calls ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh wait, my grep was bad, nevermind. |
||
|
||
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"; }; | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
{ buildPackages, runCommand, nettools, bc, perl, gmp, libmpc, mpfr, openssl | ||
, ncurses ? null | ||
, libelf | ||
, utillinux | ||
, writeTextFile, ubootTools | ||
, hostPlatform | ||
}: | ||
|
||
let | ||
|
@@ -34,7 +34,9 @@ in { | |
# Use defaultMeta // extraMeta | ||
extraMeta ? {}, | ||
# Whether to utilize the controversial import-from-derivation feature to parse the config | ||
allowImportFromDerivation ? false | ||
allowImportFromDerivation ? false, | ||
|
||
hostPlatform | ||
}: | ||
|
||
let | ||
|
@@ -86,8 +88,6 @@ let | |
inherit src; | ||
|
||
preUnpack = '' | ||
mkdir build | ||
export buildRoot="$(pwd)/build" | ||
''; | ||
|
||
patches = map (p: p.patch) kernelPatches; | ||
|
@@ -102,7 +102,25 @@ let | |
|
||
configurePhase = '' | ||
runHook preConfigure | ||
|
||
mkdir build | ||
export buildRoot="$(pwd)/build" | ||
|
||
echo "manual-config configurePhase buildRoot=$buildRoot pwd=$PWD" | ||
|
||
if [[ -z "$buildRoot" || ! -d "$buildRoot" ]]; then | ||
echo "set $buildRoot to the build folder please" | ||
exit 1 | ||
fi | ||
|
||
if [ -f "$buildRoot/.config" ]; then | ||
echo "Could not link $buildRoot/.config : file exists" | ||
exit 1 | ||
fi | ||
ln -sv ${configfile} $buildRoot/.config | ||
|
||
# reads the existing .config file and prompts the user for options in | ||
# the current kernel source that are not found in the file. | ||
make $makeFlags "''${makeFlagsArray[@]}" oldconfig | ||
runHook postConfigure | ||
|
||
|
@@ -115,6 +133,8 @@ let | |
|
||
# Note: we can get rid of this once http://permalink.gmane.org/gmane.linux.kbuild.devel/13800 is merged. | ||
buildFlagsArray+=("KBUILD_BUILD_TIMESTAMP=$(date -u -d @$SOURCE_DATE_EPOCH)") | ||
|
||
cd $buildRoot | ||
''; | ||
|
||
buildFlags = [ | ||
|
@@ -136,7 +156,7 @@ let | |
|
||
postInstall = '' | ||
mkdir -p $dev | ||
cp $buildRoot/vmlinux $dev/ | ||
cp vmlinux $dev/ | ||
'' + (optionalString installsFirmware '' | ||
mkdir -p $out/lib/firmware | ||
'') + (if (platform ? kernelDTB && platform.kernelDTB) then '' | ||
|
@@ -151,7 +171,7 @@ let | |
unlink $out/lib/modules/${modDirVersion}/source | ||
|
||
mkdir -p $dev/lib/modules/${modDirVersion}/build | ||
cp -dpR ../$sourceRoot $dev/lib/modules/${modDirVersion}/source | ||
cp -dpR .. $dev/lib/modules/${modDirVersion}/source | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm. Does this now copy way too much to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a problem I realized while testing with nox-review, I moved the build folder to within source (aka someFolder/source/build) so that it looks more like other packages (cmake-based etc). It used to have this architecture: To sum up, it should be exactly the same as before. my nox-review has been running for a day but it still hasn't met any error so I without further comments I consider the PR ready. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nevermind looks like I haven't pushed the latest changes. Need to rebase with the new kernel updates on master too :'( |
||
cd $dev/lib/modules/${modDirVersion}/source | ||
|
||
cp $buildRoot/{.config,Module.symvers} $dev/lib/modules/${modDirVersion}/build | ||
|
@@ -170,7 +190,7 @@ let | |
# from drivers/ in the future; it adds 50M to keep all of its | ||
# headers on 3.10 though. | ||
|
||
chmod u+w -R ../source | ||
chmod u+w -R .. | ||
arch=$(cd $dev/lib/modules/${modDirVersion}/build/arch; ls) | ||
|
||
# Remove unused arches | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the intention here. Most of the parameters are unused, and having
buildPackages
(and others) twice is a bit confusing...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point. Sorry I missed this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this PR as setting up the inlining of manual-config.nix into generic.nix. we can probably kill many callPackages with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copy pasted from manual-config.nix and forgot to trim it down. Will do in #34351 (comment) sorry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When doing this, we might also clean up the parameters in
<nixpkgs/pkgs/os-specific/linux/kernel/linux-*.nix>
.