Linux kernel: Difference between revisions
imported>Artturin update the list of kernel packages because someone might want to see them but doesn't have nix installed |
imported>Makefu add out of tree packaging |
||
Line 225: | Line 225: | ||
} | } | ||
</syntaxHighlight> | </syntaxHighlight> | ||
== Packaging == | |||
=== Packaging an out-of-tree kernel Module === | |||
There are a couple of steps that you will most likely need to do a couple of things. Here is an annotated example: | |||
<syntaxHighlight lang=nix> | |||
{ stdenv, fetchFromGitHub, kernel, kmod }: | |||
stdenv.mkDerivation rec { | |||
name = "v4l2loopback-dc-${version}-${kernel.version}"; | |||
version = "1.6"; | |||
src = fetchFromGitHub { | |||
owner = "aramg"; | |||
repo = "droidcam"; | |||
rev = "v${version}"; | |||
sha256 = "1d9qpnmqa3pfwsrpjnxdz76ipk4w37bbxyrazchh4vslnfc886fx"; | |||
}; | |||
sourceRoot = "source/linux/v4l2loopback"; | |||
hardeningDisable = [ "pic" ]; # 1 | |||
nativeBuildInputs = kernel.moduleBuildDependencies; # 2 | |||
makeFlags = [ | |||
"KERNELRELEASE=${kernel.modDirVersion}" # 3 | |||
"KERNEL_DIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build" # 4 | |||
"INSTALL_MOD_PATH=$(out)" # 5 | |||
]; | |||
meta = with stdenv.lib; { | |||
description = "A kernel module to create V4L2 loopback devices"; | |||
homepage = "https://github.com/aramg/droidcam"; | |||
license = licenses.gpl2; | |||
maintainers = [ maintainers.makefu ]; | |||
platforms = platforms.linux; | |||
}; | |||
} | |||
</syntaxHighlight> | |||
1. for kernel modules it is normally necessary to disable <code>pic</code> and sometimes <code>format</code> hardening | |||
2. most of the time you will need to set the moduleBuildDependencies to build a module | |||
3. this kernel module requires the release to be set, it can be found in <code>${kernel.modDirVersion}</code> | |||
4. You need to find out how the build environment (Makefile in general) finds the kernel tree. This is sometimes <code>KDIR</code> and sometimes <code>KERNEL_DIR</code>. | |||
5. When you get the error <code>mkdir: cannot create directory '/lib': Permission denied</code> then it may be necessary to set <code>INSTALL_MOD_PATH</code>. This can be done by setting via <code>makeFlags</code> or by setting it directly in the derivation. | |||
== See also == | == See also == |