Information maybe outdated

Enable the amdgpu in the kernel modules via boot.initrd.kernelModules option:

{
  boot.initrd.kernelModules = [ "amdgpu" ];
}

And then, add rocmPackages.clr.icd to hardware.graphics.extraPackages option:

{
  hardware.graphics.extraPackages = with pkgs; [
    rocmPackages.clr.icd
  ];
}

To check whether the OpenCL driver is installed successfully, try clinfo --list.
The output should look like this:


Platform #0: AMD Accelerated Parallel Processing
 `-- Device #0: (whatever)