Files
nixpkgs/nixos/modules/hardware/facter/firmware.nix
Jörg Thalheim 3e758c612d nixos/facter: add reportPath guard to all modules
Add lib.mkIf condition checking if config.hardware.facter.reportPath != null
to all facter modules. This shortcuts the module effects when no facter
report is available, preventing unnecessary evaluation and potential errors
when the report is not provided.
2025-11-05 22:57:03 +01:00

25 lines
836 B
Nix

{ lib, config, ... }:
let
facterLib = import ./lib.nix lib;
inherit (config.hardware.facter) report;
isBaremetal = config.hardware.facter.detected.virtualisation.none.enable;
hasAmdCpu = facterLib.hasAmdCpu report;
hasIntelCpu = facterLib.hasIntelCpu report;
in
{
config = lib.mkIf (config.hardware.facter.reportPath != null && isBaremetal) {
# none (e.g. bare-metal)
# provide firmware for devices that might not have been detected by nixos-facter
hardware.enableRedistributableFirmware = lib.mkDefault true;
# update microcode
hardware.cpu.amd.updateMicrocode = lib.mkIf hasAmdCpu (
lib.mkDefault config.hardware.enableRedistributableFirmware
);
hardware.cpu.intel.updateMicrocode = lib.mkIf hasIntelCpu (
lib.mkDefault config.hardware.enableRedistributableFirmware
);
};
}