| 
									
										
										
										
											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 | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   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; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  |   ]); | 
					
						
							|  |  |  | } |