1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6 cfg = config.hardware;
7in {
8
9 imports = [
10 (mkRenamedOptionModule [ "networking" "enableRT73Firmware" ] [ "hardware" "enableRedistributableFirmware" ])
11 (mkRenamedOptionModule [ "networking" "enableIntel3945ABGFirmware" ] [ "hardware" "enableRedistributableFirmware" ])
12 (mkRenamedOptionModule [ "networking" "enableIntel2100BGFirmware" ] [ "hardware" "enableRedistributableFirmware" ])
13 (mkRenamedOptionModule [ "networking" "enableRalinkFirmware" ] [ "hardware" "enableRedistributableFirmware" ])
14 (mkRenamedOptionModule [ "networking" "enableRTL8192cFirmware" ] [ "hardware" "enableRedistributableFirmware" ])
15 ];
16
17 ###### interface
18
19 options = {
20
21 hardware.enableAllFirmware = mkOption {
22 default = false;
23 type = types.bool;
24 description = lib.mdDoc ''
25 Turn on this option if you want to enable all the firmware.
26 '';
27 };
28
29 hardware.enableRedistributableFirmware = mkOption {
30 default = config.hardware.enableAllFirmware;
31 defaultText = lib.literalExpression "config.hardware.enableAllFirmware";
32 type = types.bool;
33 description = lib.mdDoc ''
34 Turn on this option if you want to enable all the firmware with a license allowing redistribution.
35 '';
36 };
37
38 hardware.wirelessRegulatoryDatabase = mkOption {
39 default = false;
40 type = types.bool;
41 description = lib.mdDoc ''
42 Load the wireless regulatory database at boot.
43 '';
44 };
45
46 };
47
48
49 ###### implementation
50
51 config = mkMerge [
52 (mkIf (cfg.enableAllFirmware || cfg.enableRedistributableFirmware) {
53 hardware.firmware = with pkgs; [
54 linux-firmware
55 intel2200BGFirmware
56 rtl8192su-firmware
57 rt5677-firmware
58 rtl8723bs-firmware
59 rtl8761b-firmware
60 rtw88-firmware
61 zd1211fw
62 alsa-firmware
63 sof-firmware
64 libreelec-dvb-firmware
65 ] ++ optional pkgs.stdenv.hostPlatform.isAarch raspberrypiWirelessFirmware
66 ++ optionals (versionOlder config.boot.kernelPackages.kernel.version "4.13") [
67 rtl8723bs-firmware
68 ];
69 hardware.wirelessRegulatoryDatabase = true;
70 })
71 (mkIf cfg.enableAllFirmware {
72 assertions = [{
73 assertion = !cfg.enableAllFirmware || config.nixpkgs.config.allowUnfree;
74 message = ''
75 the list of hardware.enableAllFirmware contains non-redistributable licensed firmware files.
76 This requires nixpkgs.config.allowUnfree to be true.
77 An alternative is to use the hardware.enableRedistributableFirmware option.
78 '';
79 }];
80 hardware.firmware = with pkgs; [
81 broadcom-bt-firmware
82 b43Firmware_5_1_138
83 b43Firmware_6_30_163_46
84 xow_dongle-firmware
85 ] ++ optionals pkgs.stdenv.hostPlatform.isx86 [
86 facetimehd-calibration
87 facetimehd-firmware
88 ];
89 })
90 (mkIf cfg.wirelessRegulatoryDatabase {
91 hardware.firmware = [ pkgs.wireless-regdb ];
92 })
93 ];
94}