nixos-config/pkgs/linux-bluetooth.nix

48 lines
902 B
Nix
Raw Normal View History

2024-10-18 00:01:43 -03:00
{
pkgs,
lib,
kernel ? pkgs.linuxPackages_latest.kernel,
patches ? [ ],
}:
pkgs.stdenv.mkDerivation {
pname = "bluetooth-kernel-module";
inherit (kernel)
src
version
postPatch
nativeBuildInputs
;
inherit patches;
kernel_dev = kernel.dev;
kernelVersion = kernel.modDirVersion;
modulePath = "drivers/bluetooth";
buildPhase = ''
BUILT_KERNEL=$kernel_dev/lib/modules/$kernelVersion/build
cp $BUILT_KERNEL/Module.symvers .
cp $BUILT_KERNEL/.config .
cp $kernel_dev/vmlinux .
make "-j$NIX_BUILD_CORES" modules_prepare
make "-j$NIX_BUILD_CORES" M=$modulePath modules
'';
installPhase = ''
make \
INSTALL_MOD_PATH="$out" \
XZ="xz -T$NIX_BUILD_CORES" \
M="$modulePath" \
modules_install
'';
meta = {
description = "Bluetooth kernel module";
license = lib.licenses.gpl3;
};
}