nixos/modules/hardware/firmware/default.nix

46 lines
887 B
Nix
Raw Normal View History

2023-11-07 22:00:00 +01:00
{ config, lib, ... }:
2023-03-18 14:40:57 +01:00
let
cfg = config.my.hardware.firmware;
in
{
2025-09-21 18:40:36 +02:00
options.my.hardware.firmware = {
enable = lib.mkEnableOption "firmware configuration";
2023-03-18 14:40:57 +01:00
2025-09-21 18:40:36 +02:00
cpuFlavor = lib.mkOption {
type = lib.types.nullOr (
lib.types.enum [
2024-07-28 21:08:02 +02:00
"intel"
"amd"
2025-09-21 18:40:36 +02:00
]
);
2023-03-18 14:40:57 +01:00
default = null;
example = "intel";
description = "Which kind of CPU to activate micro-code updates";
};
};
2024-07-28 21:08:02 +02:00
config = lib.mkIf cfg.enable (
lib.mkMerge [
{
hardware = {
enableRedistributableFirmware = true;
};
}
2023-03-18 14:40:57 +01:00
2024-07-28 21:08:02 +02:00
# Intel CPU
(lib.mkIf (cfg.cpuFlavor == "intel") {
hardware = {
cpu.intel.updateMicrocode = true;
};
})
2023-03-18 14:40:57 +01:00
2024-07-28 21:08:02 +02:00
# AMD CPU
(lib.mkIf (cfg.cpuFlavor == "amd") {
hardware = {
cpu.amd.updateMicrocode = true;
};
})
]
);
2023-03-18 14:40:57 +01:00
}