Skip to content

Instantly share code, notes, and snippets.

@pete3n
Last active May 22, 2024 13:05
Show Gist options
  • Save pete3n/68155969a76404c009e94e34fb162c4c to your computer and use it in GitHub Desktop.
Save pete3n/68155969a76404c009e94e34fb162c4c to your computer and use it in GitHub Desktop.
Out-of-tree NXP WiFi kernel module Nix build derivation

Out of tree NXP WiFi Kernel module

Build with

nix-build -E 'with import <nixpkgs> {}; callPackage ./build_nxp_wifi_kmod.nix {}'
{
lib,
stdenv,
fetchFromGitHub,
linuxPackages,
pkgs,
}: let
kernel = pkgs.linuxPackages.kernel;
makeFlagsStr = lib.concatStringsSep " " (kernel.makeFlags
++ [
"KERNELDIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
"INSTALL_MOD_PATH=$(out)"
]);
in
stdenv.mkDerivation {
pname = "nxp-wifi-driver";
version = "lf-6.6.3_1.0.0";
src = fetchFromGitHub {
owner = "nxp-imx";
repo = "mwifiex";
rev = "lf-6.6.3_1.0.0";
sha256 = "sha256-4RnvJN2vo0DF2kOuWfamn64tQaopcaEiSSIQMFZn6fg=";
};
nativeBuildInputs =
kernel.moduleBuildDependencies
++ [
pkgs.bc
pkgs.kmod
];
buildPhase = ''
cd mxm_wifiex/wlan_src
make ${makeFlagsStr} build
'';
installPhase = ''
echo "Checking for built kernel modules:"
find . -name "*.ko" -exec ls -l {} \;
mkdir -p $out/lib/modules/${kernel.modDirVersion}/extra
find . -name "*.ko" -exec cp {} $out/lib/modules/${kernel.modDirVersion}/extra/ \;
echo "Contents of $out/lib/modules/${kernel.modDirVersion}/extra:"
ls -l $out/lib/modules/${kernel.modDirVersion}/extra
'';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment