nixos/hardware.enableAllFirmware: remove with lib;

This commit is contained in:
Felix Buehler 2024-08-27 20:42:51 +02:00
parent be8d4ec87e
commit 930af3e533

View File

@ -1,33 +1,30 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.hardware; cfg = config.hardware;
in { in {
imports = [ imports = [
(mkRenamedOptionModule [ "networking" "enableRT73Firmware" ] [ "hardware" "enableRedistributableFirmware" ]) (lib.mkRenamedOptionModule [ "networking" "enableRT73Firmware" ] [ "hardware" "enableRedistributableFirmware" ])
(mkRenamedOptionModule [ "networking" "enableIntel3945ABGFirmware" ] [ "hardware" "enableRedistributableFirmware" ]) (lib.mkRenamedOptionModule [ "networking" "enableIntel3945ABGFirmware" ] [ "hardware" "enableRedistributableFirmware" ])
(mkRenamedOptionModule [ "networking" "enableIntel2100BGFirmware" ] [ "hardware" "enableRedistributableFirmware" ]) (lib.mkRenamedOptionModule [ "networking" "enableIntel2100BGFirmware" ] [ "hardware" "enableRedistributableFirmware" ])
(mkRenamedOptionModule [ "networking" "enableRalinkFirmware" ] [ "hardware" "enableRedistributableFirmware" ]) (lib.mkRenamedOptionModule [ "networking" "enableRalinkFirmware" ] [ "hardware" "enableRedistributableFirmware" ])
(mkRenamedOptionModule [ "networking" "enableRTL8192cFirmware" ] [ "hardware" "enableRedistributableFirmware" ]) (lib.mkRenamedOptionModule [ "networking" "enableRTL8192cFirmware" ] [ "hardware" "enableRedistributableFirmware" ])
]; ];
###### interface ###### interface
options = { options = {
hardware.enableAllFirmware = mkEnableOption "all firmware regardless of license"; hardware.enableAllFirmware = lib.mkEnableOption "all firmware regardless of license";
hardware.enableRedistributableFirmware = mkEnableOption "firmware with a license allowing redistribution" // { hardware.enableRedistributableFirmware = lib.mkEnableOption "firmware with a license allowing redistribution" // {
default = config.hardware.enableAllFirmware; default = config.hardware.enableAllFirmware;
defaultText = lib.literalExpression "config.hardware.enableAllFirmware"; defaultText = lib.literalExpression "config.hardware.enableAllFirmware";
}; };
hardware.wirelessRegulatoryDatabase = mkEnableOption "loading the wireless regulatory database at boot" // { hardware.wirelessRegulatoryDatabase = lib.mkEnableOption "loading the wireless regulatory database at boot" // {
default = cfg.enableRedistributableFirmware || cfg.enableAllFirmware; default = cfg.enableRedistributableFirmware || cfg.enableAllFirmware;
defaultText = literalMD "Enabled if proprietary firmware is allowed via {option}`enableRedistributableFirmware` or {option}`enableAllFirmware`."; defaultText = lib.literalMD "Enabled if proprietary firmware is allowed via {option}`enableRedistributableFirmware` or {option}`enableAllFirmware`.";
}; };
}; };
@ -35,8 +32,8 @@ in {
###### implementation ###### implementation
config = mkMerge [ config = lib.mkMerge [
(mkIf (cfg.enableAllFirmware || cfg.enableRedistributableFirmware) { (lib.mkIf (cfg.enableAllFirmware || cfg.enableRedistributableFirmware) {
hardware.firmware = with pkgs; [ hardware.firmware = with pkgs; [
linux-firmware linux-firmware
intel2200BGFirmware intel2200BGFirmware
@ -47,9 +44,9 @@ in {
alsa-firmware alsa-firmware
sof-firmware sof-firmware
libreelec-dvb-firmware libreelec-dvb-firmware
] ++ optional pkgs.stdenv.hostPlatform.isAarch raspberrypiWirelessFirmware; ] ++ lib.optional pkgs.stdenv.hostPlatform.isAarch raspberrypiWirelessFirmware;
}) })
(mkIf cfg.enableAllFirmware { (lib.mkIf cfg.enableAllFirmware {
assertions = [{ assertions = [{
assertion = !cfg.enableAllFirmware || pkgs.config.allowUnfree; assertion = !cfg.enableAllFirmware || pkgs.config.allowUnfree;
message = '' message = ''
@ -63,12 +60,12 @@ in {
b43Firmware_5_1_138 b43Firmware_5_1_138
b43Firmware_6_30_163_46 b43Firmware_6_30_163_46
xow_dongle-firmware xow_dongle-firmware
] ++ optionals pkgs.stdenv.hostPlatform.isx86 [ ] ++ lib.optionals pkgs.stdenv.hostPlatform.isx86 [
facetimehd-calibration facetimehd-calibration
facetimehd-firmware facetimehd-firmware
]; ];
}) })
(mkIf cfg.wirelessRegulatoryDatabase { (lib.mkIf cfg.wirelessRegulatoryDatabase {
hardware.firmware = [ pkgs.wireless-regdb ]; hardware.firmware = [ pkgs.wireless-regdb ];
}) })
]; ];