{
  lib,
  config,
  pkgs,
  ...
}: let
  cfg = config.myConfig.gpu.amd;
in {
  options.myConfig.gpu.amd = {
    enable = lib.mkEnableOption "enable amd gpu hardware acceleration";
  };

  config = lib.mkIf cfg.enable {
    boot.initrd.kernelModules = ["amdgpu"];
    services.xserver.videoDrivers = ["amdgpu"];

    systemd.tmpfiles.rules = [
      "L+    /opt/rocm/hip   -    -    -     -    ${pkgs.rocmPackages.clr}"
    ];

    hardware.graphics = {
      enable = true;
      enable32Bit = true;
      extraPackages = with pkgs; [
        rocmPackages.clr.icd
        rocmPackages.rocm-smi
        amdvlk
      ];
      extraPackages32 = with pkgs; [
        driversi686Linux.amdvlk
      ];
    };

    environment.systemPackages = with pkgs; [
      glxinfo
      vulkan-tools
      gpu-viewer
    ];
  };
}
