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.
This commit is contained in:
Jörg Thalheim 2017-05-08 08:50:03 +01:00
parent 6e738df176
commit 05aa80c06a
No known key found for this signature in database
GPG key ID: CA4106B8D7CC79FA
16 changed files with 51 additions and 28 deletions

View file

@ -2,7 +2,9 @@
with lib; with lib;
{ let
cfg = config.hardware;
in {
###### interface ###### interface
@ -12,7 +14,16 @@ with lib;
default = false; default = false;
type = types.bool; type = types.bool;
description = '' 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 ###### implementation
config = mkIf config.hardware.enableAllFirmware { config = mkMerge [
hardware.firmware = with pkgs; [ (mkIf (cfg.enableAllFirmware || cfg.enableRedistributalFirmware) {
firmwareLinuxNonfree hardware.firmware = with pkgs; [
intel2200BGFirmware firmwareLinuxNonfree
rtl8723bs-firmware intel2200BGFirmware
rtl8192su-firmware rtl8723bs-firmware
] ++ optionals config.nixpkgs.config.allowUnfree [ rtl8192su-firmware
broadcom-bt-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
];
})
];
} }

View file

@ -1,3 +1,3 @@
{ {
hardware.enableAllFirmware = true; hardware.enableRedistributalFirmware = true;
} }

View file

@ -1,3 +1,3 @@
{ {
hardware.enableAllFirmware = true; hardware.enableRedistributalFirmware = true;
} }

View file

@ -23,7 +23,7 @@
config = lib.mkIf config.networking.enableIntel2100BGFirmware { config = lib.mkIf config.networking.enableIntel2100BGFirmware {
hardware.enableAllFirmware = true; hardware.enableRedistributalFirmware = true;
}; };

View file

@ -22,7 +22,7 @@
config = lib.mkIf config.networking.enableIntel3945ABGFirmware { config = lib.mkIf config.networking.enableIntel3945ABGFirmware {
hardware.enableAllFirmware = true; hardware.enableRedistributalFirmware = true;
}; };

View file

@ -1,3 +1,3 @@
{ {
hardware.enableAllFirmware = true; hardware.enableRedistributalFirmware = true;
} }

View file

@ -1,3 +1,3 @@
{ {
hardware.enableAllFirmware = true; hardware.enableRedistributalFirmware = true;
} }

View file

@ -1,3 +1,3 @@
{ {
hardware.enableAllFirmware = true; hardware.enableRedistributalFirmware = true;
} }

View file

@ -1,3 +1,3 @@
{ {
hardware.enableAllFirmware = true; hardware.enableRedistributalFirmware = true;
} }

View file

@ -1,3 +1,3 @@
{ {
hardware.enableAllFirmware = true; hardware.enableRedistributalFirmware = true;
} }

View file

@ -1,3 +1,3 @@
{ {
hardware.enableAllFirmware = true; hardware.enableRedistributalFirmware = true;
} }

View file

@ -20,7 +20,7 @@
###### implementation ###### implementation
config = lib.mkIf config.networking.enableRalinkFirmware { config = lib.mkIf config.networking.enableRalinkFirmware {
hardware.enableAllFirmware = true; hardware.enableRedistributalFirmware = true;
}; };
} }

View file

@ -20,7 +20,7 @@
###### implementation ###### implementation
config = lib.mkIf config.networking.enableRTL8192cFirmware { config = lib.mkIf config.networking.enableRTL8192cFirmware {
hardware.enableAllFirmware = true; hardware.enableRedistributalFirmware = true;
}; };
} }

View file

@ -1,3 +1,3 @@
{ {
hardware.enableAllFirmware = true; hardware.enableRedistributalFirmware = true;
} }

View file

@ -5,5 +5,5 @@
with lib; with lib;
{ {
hardware.enableAllFirmware = true; hardware.enableRedistributalFirmware = true;
} }

View file

@ -50,7 +50,7 @@
]; ];
# Include lots of firmware. # Include lots of firmware.
hardware.enableAllFirmware = true; hardware.enableRedistributalFirmware = true;
imports = imports =
[ ../hardware/network/zydas-zd1211.nix ]; [ ../hardware/network/zydas-zd1211.nix ];