diff --git a/legacy/modules/intel.nix b/legacy/modules/intel.nix deleted file mode 100644 index 237a74b..0000000 --- a/legacy/modules/intel.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ config, lib, pkgs, ... }: - -{ - hardware.cpu.intel.updateMicrocode = true; -} diff --git a/machines/thinkman/hardware-configuration.nix b/machines/thinkman/hardware-configuration.nix index 6608449..fc24650 100644 --- a/machines/thinkman/hardware-configuration.nix +++ b/machines/thinkman/hardware-configuration.nix @@ -11,5 +11,9 @@ nitrokey.enable = true; sound.enable = true; thunderbolt.enable = true; + firmware = { + enable = true; + cpuFlavor = "intel"; + }; }; } diff --git a/modules/hardware/default.nix b/modules/hardware/default.nix index 94e8f7c..fae9928 100644 --- a/modules/hardware/default.nix +++ b/modules/hardware/default.nix @@ -3,6 +3,7 @@ { imports = [ + ./firmware ./keychron ./nitrokey ./sound diff --git a/modules/hardware/firmware/default.nix b/modules/hardware/firmware/default.nix new file mode 100644 index 0000000..5d3f63d --- /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 = mkEnableOption "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; + }; + }) + ]); +}