config/hardware/gpu/rocm.nix

38 lines
1.4 KiB
Nix

{ pkgs, lib, ... }:
{
# assumes common-gpu-amd from nixos-hardware is also added
# TODO: should we move it from flake.nix to here?
# https://github.com/NixOS/nixos-hardware/blob/master/common/gpu/amd/default.nix
hardware.opengl.enable = true;
hardware.opengl.driSupport = true;
hardware.opengl.driSupport32Bit = true;
nixpkgs.config.openglSupport = true; # why is this not set by hardware.opengl.enable ?
nixpkgs.config.rocmSupport = true;
nixpkgs.config.vdpauSupport = true;
nixpkgs.config.vaapiSupport = true;
# nixos-hardware common-amd options
# https://github.com/NixOS/nixos-hardware/blob/master/common/gpu/amd/default.nix
hardware.amdgpu.opencl = lib.mkDefault true;
hardware.amdgpu.amdvlk = lib.mkDefault false;
# https://libreddit.noximilien.pbsds.net/r/archlinux/comments/nih9c9/amdgpu_vs_modesetting_in_current_510_kernels_xorg/
services.xserver.videoDrivers = [ "amdgpu" ]; # use gpu, adaptive sync and and hardware page flipping
#services.xserver.videoDrivers = [ "modesetting" ]; # integrated (non-accelerated) framebuffer, KMS (default in nixos-hardware)
# https://nixos.wiki/wiki/AMD_GPU#HIP
systemd.tmpfiles.rules = let
hip = if (lib.versionOlder (lib.versions.majorMinor lib.version) "23.11")
then pkgs.hip
else pkgs.rocmPackages.clr;
in [
"L+ /opt/rocm/hip - - - - ${hip}"
];
environment.systemPackages = with pkgs; [
nvtop-amd
];
}