about summary refs log tree commit diff
path: root/nixos/modules/hardware/all-firmware.nix
diff options
context:
space:
mode:
authorJörg Thalheim <joerg@thalheim.io>2017-05-08 08:50:03 +0100
committerJörg Thalheim <joerg@thalheim.io>2017-05-09 15:29:08 +0100
commit05aa80c06ab45da7c44b6bf1b858a87815665c71 (patch)
tree50a2aeffc0417ef57fe24c97183dc1112968d8d3 /nixos/modules/hardware/all-firmware.nix
parent6e738df1763d5fe94e55348635270b26d08b71d2 (diff)
hardware: add enableRedistributalFirmware
Due the recent inclusion of broadcom-bt-firmware in enableAllFirmware,
it was required to set `nixpkgs.config.allowUnfree` to obtain the full
list. To make this dependency more explicit an assertion is added and an
alternative option `enableRedistributalFirmware` is provided to only
obtain firmware with an license allowing redistribution.
Diffstat (limited to 'nixos/modules/hardware/all-firmware.nix')
-rw-r--r--nixos/modules/hardware/all-firmware.nix49
1 files changed, 36 insertions, 13 deletions
diff --git a/nixos/modules/hardware/all-firmware.nix b/nixos/modules/hardware/all-firmware.nix
index ceca3b887b58a..8f26d8f57ea4f 100644
--- a/nixos/modules/hardware/all-firmware.nix
+++ b/nixos/modules/hardware/all-firmware.nix
@@ -2,7 +2,9 @@
 
 with lib;
 
-{
+let
+  cfg = config.hardware;
+in {
 
   ###### interface
 
@@ -12,7 +14,16 @@ with lib;
       default = false;
       type = types.bool;
       description = ''
-        Turn on this option if you want to enable all the firmware shipped in linux-firmware.
+        Turn on this option if you want to enable all the firmware.
+      '';
+    };
+
+    hardware.enableRedistributalFirmware = mkOption {
+      default = false;
+      type = types.bool;
+      description = ''
+        Turn on this option if you want to enable all the firmware with a license allowing redistribution.
+        (i.e. free firmware and <literal>firmware-linux-nonfree</literal>)
       '';
     };
 
@@ -21,15 +32,27 @@ with lib;
 
   ###### implementation
 
-  config = mkIf config.hardware.enableAllFirmware {
-    hardware.firmware = with pkgs; [
-      firmwareLinuxNonfree
-      intel2200BGFirmware
-      rtl8723bs-firmware
-      rtl8192su-firmware
-    ] ++ optionals config.nixpkgs.config.allowUnfree [
-      broadcom-bt-firmware
-    ];
-  };
-
+  config = mkMerge [
+    (mkIf (cfg.enableAllFirmware || cfg.enableRedistributalFirmware) {
+      hardware.firmware = with pkgs; [
+        firmwareLinuxNonfree
+        intel2200BGFirmware
+        rtl8723bs-firmware
+        rtl8192su-firmware
+      ];
+    })
+    (mkIf cfg.enableAllFirmware {
+      assertions = [{
+        assertion = !cfg.enableAllFirmware || (config.nixpkgs.config.allowUnfree or false);
+        message = ''
+          the list of hardware.enableAllFirmware contains non-redistributable licensed firmware files.
+            This requires nixpkgs.config.allowUnfree to be true.
+            An alternative is to use the hardware.enableRedistributalFirmware option.
+        '';
+      }];
+      hardware.firmware = with pkgs; [
+        broadcom-bt-firmware
+      ];
+    })
+  ];
 }