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 = ''
25 Turn on this option if you want to enable all the firmware.
26 '';
27 };
28
29 hardware.enableRedistributableFirmware = mkOption {
30 default = false;
31 type = types.bool;
32 description = ''
33 Turn on this option if you want to enable all the firmware with a license allowing redistribution.
34 (i.e. free firmware and <literal>firmware-linux-nonfree</literal>)
35 '';
36 };
37
38 };
39
40
41 ###### implementation
42
43 config = mkMerge [
44 (mkIf (cfg.enableAllFirmware || cfg.enableRedistributableFirmware) {
45 hardware.firmware = with pkgs; [
46 firmwareLinuxNonfree
47 intel2200BGFirmware
48 rtl8192su-firmware
49 rt5677-firmware
50 rtl8723bs-firmware
51 rtl8761b-firmware
52 rtw88-firmware
53 zd1211fw
54 alsa-firmware
55 sof-firmware
56 openelec-dvb-firmware
57 ] ++ optional (pkgs.stdenv.hostPlatform.isAarch32 || pkgs.stdenv.hostPlatform.isAarch64) raspberrypiWirelessFirmware
58 ++ optionals (versionOlder config.boot.kernelPackages.kernel.version "4.13") [
59 rtl8723bs-firmware
60 ];
61 })
62 (mkIf cfg.enableAllFirmware {
63 assertions = [{
64 assertion = !cfg.enableAllFirmware || (config.nixpkgs.config.allowUnfree or false);
65 message = ''
66 the list of hardware.enableAllFirmware contains non-redistributable licensed firmware files.
67 This requires nixpkgs.config.allowUnfree to be true.
68 An alternative is to use the hardware.enableRedistributableFirmware option.
69 '';
70 }];
71 hardware.firmware = with pkgs; [
72 broadcom-bt-firmware
73 b43Firmware_5_1_138
74 b43Firmware_6_30_163_46
75 b43FirmwareCutter
76 ] ++ optional (pkgs.stdenv.hostPlatform.isi686 || pkgs.stdenv.hostPlatform.isx86_64) facetimehd-firmware;
77 })
78 ];
79}