mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-11-10 09:43:30 +01:00
This adds automatic virtualization detection (virtualisation.nix) and firmware management (firmware.nix). Builds on PR #455151 (networking). Part of incremental upstreaming from nixos-facter-modules.
25 lines
789 B
Nix
25 lines
789 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 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
|
|
);
|
|
};
|
|
}
|