freebsd.iwlwifi-firmware: init

This commit is contained in:
Artemis Tosini
2026-02-27 12:54:04 -05:00
parent 2c262455c0
commit a51a52d832
3 changed files with 89 additions and 0 deletions
@@ -0,0 +1,55 @@
{
lib,
mkDerivation,
sys,
buildFreebsd,
linux-firmware,
}:
mkDerivation rec {
# out-of-tree, but we still want to use freebsd.mkDerivation, which wants an in-tree path
path = "...";
pname = "iwlwifi-firmware";
version = linux-firmware.version;
# Upstream FreeBSD doesn't wrap wifi firmware, only gpu firmware.
# We have to write our own build scripts for this.
src = ./src;
outputs = [
"out"
"debug"
];
extraNativeBuildInputs = [ buildFreebsd.xargs-j ];
env = sys.passthru.env;
SYSDIR = "${sys.src}/sys";
KERN_DEBUGDIR = "${builtins.placeholder "debug"}/lib/debug";
KERN_DEBUGDIR_KODIR = "${KERN_DEBUGDIR}/kernel";
KERN_DEBUGDIR_KMODDIR = "${KERN_DEBUGDIR}/kernel";
KMODDIR = "${placeholder "out"}/kernel";
LINUX_FIRMWARE = "${linux-firmware}/lib/firmware";
# generates relocations the linker can't handle
hardeningDisable = [
"pic"
];
makeFlags = [
"DEBUG_FLAGS=-g"
"XARGS_J=xargs-j"
"NO_XREF=1"
];
preConfigure = ''
bash gen-makefiles
'';
meta = {
description = "Intel Wifi Firmware for FreeBSD";
platforms = lib.platforms.freebsd;
license = linux-firmware.meta.license;
};
}
@@ -0,0 +1,8 @@
KMOD= ${NAME}
FIRMWS= ${NAME}:${NAME}
CLEANFILES+= ${NAME} ${NAME}.fwo ${NAME}.ko.debug ${NAME}.ko.full
${NAME}: ${LINUX_FIRMWARE}/intel/iwlwifi/${NAME}
cp $? ${.TARGET}
@@ -0,0 +1,26 @@
set -e
scriptdir=$(cd $(dirname $0) && pwd)
fwdir=$LINUX_FIRMWARE/intel/iwlwifi
for dir in $scriptdir/*; do
if [ ! -d "$dir" ]; then
continue
fi
rm -rf "$dir"
done
for file in $fwdir/*.*; do
base=$(basename $file)
echo "SUBDIR += $base" >> Makefile
mkdir -p "$scriptdir/$base"
cat > "$scriptdir/$base/Makefile" <<EOF
NAME= $base
.include <bsd.kmod.mk>
EOF
done
echo ".include <bsd.subdir.mk>" >> Makefile