# AMD CPU + Radeon GPU. nixos-hardware (common-cpu-amd, -pstate, -gpu-amd, # -pc-ssd) is imported by the host; defaults that overlap use mkDefault. { config, lib, pkgs, ... }: let cfg = config.my.hardware.amd; in { options.my.hardware.amd = { enable = lib.mkEnableOption "AMD CPU and Radeon GPU support"; rocm.enable = lib.mkEnableOption "ROCm/HIP compute stack (rocminfo, rocm-smi, /opt/rocm/hip)"; lact.enable = lib.mkOption { type = lib.types.bool; default = true; description = "LACT daemon for GPU monitoring, fan curves and overclocking."; }; }; config = lib.mkIf cfg.enable ( lib.mkMerge [ { hardware = { graphics = { enable = true; # Steam/Proton and Wine need the 32-bit Mesa drivers. enable32Bit = true; }; amdgpu = { initrd.enable = lib.mkDefault true; opencl.enable = true; }; cpu.amd.updateMicrocode = lib.mkDefault true; }; boot.kernelModules = [ "kvm-amd" ]; environment.systemPackages = with pkgs; [ vulkan-tools mesa-demos radeontop nvtopPackages.amd lm_sensors ]; } (lib.mkIf cfg.lact.enable { services.lact.enable = true; # LACT needs the overdrive bit in amdgpu.ppfeaturemask to tune clocks. hardware.amdgpu.overdrive.enable = true; }) (lib.mkIf cfg.rocm.enable { environment.systemPackages = with pkgs.rocmPackages; [ rocminfo rocm-smi ]; # Many HIP applications look for the runtime in /opt/rocm/hip. systemd.tmpfiles.rules = [ "L+ /opt/rocm/hip - - - - ${pkgs.rocmPackages.clr}" ]; }) ] ); }