1{
2 lib,
3 stdenv,
4 fetchurl,
5 fetchFromGitHub,
6 fetchpatch2,
7 kernel,
8}:
9
10let
11 version = "6.30.223.271";
12 hashes = {
13 i686-linux = "sha256-T4twspOsjMXHDlca1dGHjQ8p0TOkb+eGmGjZwZtQWM0=";
14 x86_64-linux = "sha256-X3l3TVvuyPdja1nA+wegMQju8eP9MkVjiyCFjHFBRL4=";
15 };
16
17 arch = lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux") "_64";
18 tarballVersion = lib.replaceStrings [ "." ] [ "_" ] version;
19 tarball = "hybrid-v35${arch}-nodebug-pcoem-${tarballVersion}.tar.gz";
20
21 rpmFusionPatches = fetchFromGitHub {
22 owner = "rpmfusion";
23 repo = "wl-kmod";
24 rev = "9a5a0d7195e0f6b05ff97e948b97fb0b7427cbf2";
25 hash = "sha256-pOOkkOjc77KGqc9fWuRyRsymd90OpLEnbOvxBbeIdKQ=";
26 };
27 patchset = [
28 "wl-kmod-001_wext_workaround.patch"
29 "wl-kmod-002_kernel_3.18_null_pointer.patch"
30 "wl-kmod-003_gcc_4.9_remove_TIME_DATE_macros.patch"
31 "wl-kmod-004_kernel_4.3_rdtscl_to_rdtsc.patch"
32 "wl-kmod-005_kernel_4.7_IEEE80211_BAND_to_NL80211_BAND.patch"
33 "wl-kmod-006_gcc_6_fix_indentation_warnings.patch"
34 "wl-kmod-007_kernel_4.8_add_cfg80211_scan_info_struct.patch"
35 "wl-kmod-008_fix_kernel_warnings.patch"
36 "wl-kmod-009_kernel_4.11_remove_last_rx_in_net_device_struct.patch"
37 "wl-kmod-010_kernel_4.12_add_cfg80211_roam_info_struct.patch"
38 "wl-kmod-011_kernel_4.14_new_kernel_read_function_prototype.patch"
39 "wl-kmod-012_kernel_4.15_new_timer.patch"
40 "wl-kmod-013_gcc8_fix_bounds_check_warnings.patch"
41 "wl-kmod-014_kernel_read_pos_increment_fix.patch"
42 "wl-kmod-015_kernel_5.1_get_ds_removed.patch"
43 "wl-kmod-016_fix_unsupported_mesh_point.patch"
44 "wl-kmod-017_fix_gcc_fallthrough_warning.patch"
45 "wl-kmod-018_kernel_5.6_adaptations.patch"
46 "wl-kmod-019_kernel_5.9_segment_eq_removed.patch"
47 "wl-kmod-020_kernel_5.10_get_set_fs_removed.patch"
48 "wl-kmod-021_kernel_5.17_adaptation.patch"
49 "wl-kmod-022_kernel_5.18_adaptation.patch"
50 "wl-kmod-023_kernel_6.0_adaptation.patch"
51 "wl-kmod-024_kernel_6.1_adaptation.patch"
52 "wl-kmod-025_kernel_6.5_adaptation.patch"
53 "wl-kmod-026_kernel_6.10_fix_empty_body_in_if_warning.patch"
54 "wl-kmod-027_wpa_supplicant-2.11_add_max_scan_ie_len.patch"
55 "wl-kmod-028_kernel_6.12_adaptation.patch"
56 "wl-kmod-029_kernel_6.13_adaptation.patch"
57 "wl-kmod-030_kernel_6.14_adaptation.patch"
58 ];
59in
60stdenv.mkDerivation {
61 name = "broadcom-sta-${version}-${kernel.version}";
62
63 src = fetchurl {
64 url = "https://docs.broadcom.com/docs-and-downloads/docs/linux_sta/${tarball}";
65 hash =
66 hashes.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
67 };
68
69 hardeningDisable = [ "pic" ];
70
71 nativeBuildInputs = kernel.moduleBuildDependencies;
72
73 patches = map (patch: "${rpmFusionPatches}/${patch}") patchset;
74
75 makeFlags = [ "KBASE=${kernel.dev}/lib/modules/${kernel.modDirVersion}" ];
76
77 unpackPhase = ''
78 runHook preUnpack
79 sourceRoot=broadcom-sta
80 mkdir "$sourceRoot"
81 tar xvf "$src" -C "$sourceRoot"
82 runHook postUnpack
83 '';
84
85 installPhase = ''
86 runHook preInstall
87 binDir="$out/lib/modules/${kernel.modDirVersion}/kernel/net/wireless/"
88 docDir="$out/share/doc/broadcom-sta/"
89 mkdir -p "$binDir" "$docDir"
90 cp wl.ko "$binDir"
91 cp lib/LICENSE.txt "$docDir"
92 runHook postInstall
93 '';
94
95 meta = {
96 description = "Kernel module driver for some Broadcom's wireless cards";
97 homepage = "http://www.broadcom.com/support/802.11/linux_sta.php";
98 license = lib.licenses.unfreeRedistributable;
99 maintainers = [ lib.maintainers.j0hax ];
100 platforms = lib.platforms.linux;
101 };
102}