From 256c857ac07d7a4a8800be712f36323b400806bf Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 27 Apr 2022 13:55:00 +0200 Subject: [PATCH] modules: hardware: add firmware --- modules/hardware/default.nix | 1 + modules/hardware/firmware/default.nix | 38 +++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 modules/hardware/firmware/default.nix diff --git a/modules/hardware/default.nix b/modules/hardware/default.nix index 9ab5d40..2a686f7 100644 --- a/modules/hardware/default.nix +++ b/modules/hardware/default.nix @@ -5,6 +5,7 @@ imports = [ ./bluetooth ./ergodox + ./firmware ./mx-ergo ./networking ./sound diff --git a/modules/hardware/firmware/default.nix b/modules/hardware/firmware/default.nix new file mode 100644 index 0000000..e899232 --- /dev/null +++ b/modules/hardware/firmware/default.nix @@ -0,0 +1,38 @@ +{ config, lib, pkgs, ... }: +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; + }; + }) + ]); +}