1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6 cfg = config.hardware;
7in {
8
9 ###### interface
10
11 options = {
12
13 hardware.enableAllFirmware = mkOption {
14 default = false;
15 type = types.bool;
16 description = ''
17 Turn on this option if you want to enable all the firmware.
18 '';
19 };
20
21 hardware.enableRedistributableFirmware = mkOption {
22 default = false;
23 type = types.bool;
24 description = ''
25 Turn on this option if you want to enable all the firmware with a license allowing redistribution.
26 (i.e. free firmware and <literal>firmware-linux-nonfree</literal>)
27 '';
28 };
29
30 };
31
32
33 ###### implementation
34
35 config = mkMerge [
36 (mkIf (cfg.enableAllFirmware || cfg.enableRedistributableFirmware) {
37 hardware.firmware = with pkgs; [
38 firmwareLinuxNonfree
39 intel2200BGFirmware
40 rtl8192su-firmware
41 ] ++ optionals (versionOlder config.boot.kernelPackages.kernel.version "4.13") [
42 rtl8723bs-firmware
43 ];
44 })
45 (mkIf cfg.enableAllFirmware {
46 assertions = [{
47 assertion = !cfg.enableAllFirmware || (config.nixpkgs.config.allowUnfree or false);
48 message = ''
49 the list of hardware.enableAllFirmware contains non-redistributable licensed firmware files.
50 This requires nixpkgs.config.allowUnfree to be true.
51 An alternative is to use the hardware.enableRedistributableFirmware option.
52 '';
53 }];
54 hardware.firmware = with pkgs; [
55 broadcom-bt-firmware
56 ];
57 })
58 ];
59}