forked from koverstreet/ktest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kernel_install.nix
37 lines (37 loc) · 1.36 KB
/
kernel_install.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{ linuxManualConfig, buildPackages, src, buildRoot, kernelVersion ? "6.1.0", ...}:
let
version = "${kernelVersion}-ktest";
modDirVersion = "${kernelVersion}-ktest";
in
(linuxManualConfig {
inherit src version modDirVersion;
configfile = "${buildRoot}/.config";
allowImportFromDerivation = true;
}).overrideAttrs (attrs: attrs // {
dontStrip = true;
phases = [ "buildPhase" "installPhase"] ;
nativeBuildInputs = [ buildPackages.kmod ] ++ attrs.nativeBuildInputs;
buildPhase = ''
export buildRoot="$(pwd)/build"
cp -r ${buildRoot} $buildRoot
chmod +rw -R $buildRoot
rm $buildRoot/Makefile
echo "include ${src}/Makefile" > $buildRoot/Makefile
actualModDirVersion="$(cat $buildRoot/include/config/kernel.release)"
if [ "$actualModDirVersion" != "${modDirVersion}" ]; then
echo "Error: modDirVersion ${modDirVersion} specified in the Nix expression is wrong, it should be: $actualModDirVersion"
exit 1
fi
cd $buildRoot
'';
postInstall = ''
if [ -z "''${dontStrip-}" ]; then
installFlagsArray+=("INSTALL_MOD_STRIP=1")
fi
make modules_install $makeFlags "''${makeFlagsArray[@]}" \
$installFlags "''${installFlagsArray[@]}"
unlink $out/lib/modules/${modDirVersion}/build
unlink $out/lib/modules/${modDirVersion}/source
'';
outputs = [ "out" ];
})