nix-config/modules/nixos/hardware/firmware/default.nix
Bruno BELANYI c856933803 nixos: create 'modules/nixos' folder
Let's consolidate all modules under one path, so that NixOS,
home-manager, and nix-darwin (if I ever end up using it down the line)
would go under the same folder.
2023-11-11 18:11:52 +00:00

39 lines
797 B
Nix

{ config, lib, ... }:
let
cfg = config.my.hardware.firmware;
in
{
options.my.hardware.firmware = with lib; {
enable = my.mkDisableOption "firmware configuration";
cpuFlavor = mkOption {
type = with types; nullOr (enum [ "intel" "amd" ]);
default = null;
example = "intel";
description = "Which kind of CPU to activate micro-code updates";
};
};
config = lib.mkIf cfg.enable (lib.mkMerge [
{
hardware = {
enableRedistributableFirmware = true;
};
}
# Intel CPU
(lib.mkIf (cfg.cpuFlavor == "intel") {
hardware = {
cpu.intel.updateMicrocode = true;
};
})
# AMD CPU
(lib.mkIf (cfg.cpuFlavor == "amd") {
hardware = {
cpu.amd.updateMicrocode = true;
};
})
]);
}