linuxManualConfig: unpack directly into $dev
linux is unusual in that we include its sources in an output. There's no point unpacking into /build when we're going to copy the sources into $dev later. Let's unpack directly into the final destination of the code, and save copying a whole kernel source tree (often across filesystems!). This also means that Kbuild knows the location of the sources, which will allow us to install the GDB scripts — some scripts are generated, and some are not, so the generated ones end up in the build directory, accompanied by symlinks to the non-generated ones in the source directory.
This commit is contained in:
parent
d75cff2ee3
commit
7de3f08ce3
@ -115,6 +115,20 @@ let
|
||||
hash = "sha256-bBOyJcP6jUvozFJU0SPTOf3cmnTQ6ZZ4PlHjiniHXLU=";
|
||||
});
|
||||
|
||||
preUnpack = ''
|
||||
# The same preUnpack is used to build the configfile,
|
||||
# which does not have $dev.
|
||||
if [ -n "$dev" ]; then
|
||||
mkdir -p $dev/lib/modules/${modDirVersion}
|
||||
cd $dev/lib/modules/${modDirVersion}
|
||||
fi
|
||||
'';
|
||||
|
||||
postUnpack = ''
|
||||
mv -Tv "$sourceRoot" source 2>/dev/null || :
|
||||
export sourceRoot=$PWD/source
|
||||
'';
|
||||
|
||||
postPatch = ''
|
||||
sed -i Makefile -e 's|= depmod|= ${buildPackages.kmod}/bin/depmod|'
|
||||
|
||||
@ -185,6 +199,12 @@ let
|
||||
|
||||
buildFlags = [
|
||||
"KBUILD_BUILD_VERSION=1-NixOS"
|
||||
|
||||
# Set by default in the kernel since a73619a845d5,
|
||||
# replicated here to apply to older versions.
|
||||
# Makes __FILE__ relative to the build directory.
|
||||
"KCPPFLAGS=-fmacro-prefix-map=$(sourceRoot)/="
|
||||
|
||||
kernelConf.target
|
||||
"vmlinux" # for "perf" and things like that
|
||||
] ++ optional isModular "modules"
|
||||
@ -261,7 +281,6 @@ let
|
||||
];
|
||||
|
||||
postInstall = optionalString isModular ''
|
||||
mkdir -p $dev
|
||||
cp vmlinux $dev/
|
||||
if [ -z "''${dontStrip-}" ]; then
|
||||
installFlagsArray+=("INSTALL_MOD_STRIP=1")
|
||||
@ -271,12 +290,7 @@ let
|
||||
unlink $out/lib/modules/${modDirVersion}/build
|
||||
unlink $out/lib/modules/${modDirVersion}/source
|
||||
|
||||
mkdir -p $dev/lib/modules/${modDirVersion}/{build,source}
|
||||
|
||||
# To save space, exclude a bunch of unneeded stuff when copying.
|
||||
(cd "$NIX_BUILD_TOP" && cd "$sourceRoot" &&
|
||||
rsync --archive --prune-empty-dirs \
|
||||
* $dev/lib/modules/${modDirVersion}/source/)
|
||||
mkdir $dev/lib/modules/${modDirVersion}/build
|
||||
|
||||
cd $dev/lib/modules/${modDirVersion}/source
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user