-
Notifications
You must be signed in to change notification settings - Fork 1
/
kernel-module-ath-patched.nix
56 lines (44 loc) · 1.65 KB
/
kernel-module-ath-patched.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{ pkgs
, lib
, kernel ? pkgs.linuxPackages_latest.kernel
}:
pkgs.stdenv.mkDerivation {
pname = "kernel-module-ath-patched";
inherit (kernel) src version postPatch nativeBuildInputs;
kernel_dev = kernel.dev;
kernelVersion = kernel.modDirVersion;
patches = [
(pkgs.fetchpatch { # Force Atheros drivers to respect the user's regdomain settings with ATH_USER_REGD option
url = "https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob_plain;f=package/kernel/mac80211/patches/ath/402-ath_regd_optional.patch;h=601ebdc7583c2331735e45c75e77a35f31739f76;hb=HEAD";
hash = "sha256-t5DPUjcohgPuPpoaNpMbgRNjFoxfa8YXU5dkSKGwMJc=";
postFetch = ''
substituteInPlace $out --replace "CPTCFG_" "CONFIG_" # OpenWRT patches are meant to linux-backport's drivers
'';
excludes = ["local-symbols"]; # file specific to OpenWRT packaging
})
];
modulePath = "drivers/net/wireless/ath";
buildPhase = ''
BUILT_KERNEL=$kernel_dev/lib/modules/$kernelVersion/build
cp $BUILT_KERNEL/Module.symvers .
cp $BUILT_KERNEL/.config .
chmod +w .config
echo "CONFIG_ATH_USER_REGD=y" >> .config
echo "CONFIG_ATH_REG_DYNAMIC_USER_REG_HINTS=y" >> .config
echo "CONFIG_ATH_REG_DYNAMIC_USER_CERT_TESTING=y" >> .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 = "Atheros kernel module with some OpenWRT patches";
license = lib.licenses.gpl3;
};
}