From c9a89035b52d881d1f67fb73a1bbd9a9cd330771 Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Tue, 24 Dec 2024 00:37:33 +0100 Subject: [PATCH] support hardware.graphics --- hardware/gpu/intel.nix | 40 +++++++++++++++++++++---------------- hardware/gpu/rocm.nix | 26 +++++++++++------------- profiles/desktop/lutris.nix | 13 +++++++----- profiles/desktop/steam.nix | 11 +++++++--- 4 files changed, 51 insertions(+), 39 deletions(-) diff --git a/hardware/gpu/intel.nix b/hardware/gpu/intel.nix index 8a3caef..cd90643 100644 --- a/hardware/gpu/intel.nix +++ b/hardware/gpu/intel.nix @@ -1,4 +1,20 @@ { config, pkgs, lib, ... }: +let + extraPackages = with pkgs; [ + mesa.drivers + intel-media-driver + # not added due to collision + # https://github.com/NixOS/nixos-hardware/issues/1170 + #(if (lib.versionOlder (lib.versions.majorMinor lib.version) "23.11") + # then vaapiIntel + # else intel-vaapi-driver) + vaapiVdpau + libvdpau-va-gl + intel-ocl + intel-compute-runtime # OpenCL filter support (hardware tonemapping and subtitle burn-in) + (pkgs.nvtopPackages.intel or pkgs.nvtop-intel) + ]; +in lib.mkMerge [ { @@ -19,25 +35,15 @@ lib.mkMerge [ intel-vaapi-driver = pkgs.intel-vaapi-driver.override { enableHybridCodec = true; }; }; - hardware.opengl.enable = true; } (lib.optionalAttrs (lib.versionOlder (lib.versions.majorMinor lib.version) "24.11") { hardware.opengl.driSupport = true; + hardware.opengl.enable = true; + hardware.opengl.extraPackages = extraPackages; }) -{ - hardware.opengl.extraPackages = with pkgs; [ - mesa.drivers - intel-media-driver - # not added due to collision - # https://github.com/NixOS/nixos-hardware/issues/1170 - #(if (lib.versionOlder (lib.versions.majorMinor lib.version) "23.11") - # then vaapiIntel - # else intel-vaapi-driver) - vaapiVdpau - libvdpau-va-gl - intel-ocl - intel-compute-runtime # OpenCL filter support (hardware tonemapping and subtitle burn-in) - (pkgs.nvtopPackages.intel or pkgs.nvtop-intel) - ]; -} +(lib.optionalAttrs (lib.versionAtLeast (lib.versions.majorMinor lib.version) "24.11") { + hardware.graphics.enable = true; + hardware.graphics.extraPackages = extraPackages; +}) + ] diff --git a/hardware/gpu/rocm.nix b/hardware/gpu/rocm.nix index efc13d8..00f0b1d 100644 --- a/hardware/gpu/rocm.nix +++ b/hardware/gpu/rocm.nix @@ -1,12 +1,18 @@ { pkgs, lib, options, ... }: lib.mkMerge [ -{ - # 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 +# 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 +(lib.mkIf (lib.versionOlder (lib.versions.majorMinor lib.version) "24.11") { hardware.opengl.enable = true; hardware.opengl.driSupport = true; hardware.opengl.driSupport32Bit = true; +}) +(lib.mkIf (lib.versionAtLeast (lib.versions.majorMinor lib.version) "24.11") { + hardware.graphics.enable = true; + hardware.graphics.enable32Bit = true; +}) +{ nixpkgs.config.openglSupport = true; # why is this not set by hardware.opengl.enable ? nixpkgs.config.rocmSupport = true; @@ -14,19 +20,11 @@ nixpkgs.config.vaapiSupport = true; services.ollama.acceleration = lib.mkDefault "rocm"; -} -(lib.mkIf (lib.versionAtLeast (lib.versions.majorMinor lib.version) "24.05") { + hardware.amdgpu.opencl.enable = lib.mkDefault true; #hardware.amdgpu.amdvlk.enable = lib.mkDefault true; #hardware.amdgpu.amdvlk.support32Bit.enable = lib.mkDefault true; -}) -#(lib.mkIf (lib.versionOlder (lib.versions.majorMinor lib.version) "24.05") { -# # 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 true; -#}) -{ + # 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) diff --git a/profiles/desktop/lutris.nix b/profiles/desktop/lutris.nix index 33bf862..c2297ed 100644 --- a/profiles/desktop/lutris.nix +++ b/profiles/desktop/lutris.nix @@ -29,14 +29,17 @@ lib.mkMerge [ ]; - hardware.opengl.enable = true; } (lib.optionalAttrs (lib.versionOlder (lib.versions.majorMinor lib.version) "24.11") { + hardware.opengl.enable = true; hardware.opengl.driSupport = true; + hardware.opengl.driSupport32Bit = true; + hardware.opengl.extraPackages32 = with pkgs.pkgsi686Linux; [ libva ]; +}) +(lib.optionalAttrs (lib.versionAtLeast (lib.versions.majorMinor lib.version) "24.11") { + hardware.graphics.enable = true; + hardware.graphics.enable32Bit = true; + hardware.graphics.extraPackages32 = with pkgs.pkgsi686Linux; [ libva ]; }) -{ - hardware.opengl.driSupport32Bit = true; - hardware.opengl.extraPackages32 = with pkgs.pkgsi686Linux; [ libva ]; -} ] diff --git a/profiles/desktop/steam.nix b/profiles/desktop/steam.nix index cc0a3db..b28b100 100644 --- a/profiles/desktop/steam.nix +++ b/profiles/desktop/steam.nix @@ -66,14 +66,19 @@ lib.mkMerge [ #services.joycond.enable = true; - hardware.opengl.enable = true; } (lib.optionalAttrs (lib.versionOlder (lib.versions.majorMinor lib.version) "24.11") { + hardware.opengl.enable = true; hardware.opengl.driSupport = true; + hardware.opengl.driSupport32Bit = true; + hardware.opengl.extraPackages32 = with pkgs.pkgsi686Linux; [ libva ]; +}) +(lib.optionalAttrs (lib.versionAtLeast (lib.versions.majorMinor lib.version) "24.11") { + hardware.graphics.enable = true; + hardware.graphics.enable32Bit = true; + hardware.graphics.extraPackages32 = with pkgs.pkgsi686Linux; [ libva ]; }) { - hardware.opengl.driSupport32Bit = true; - hardware.opengl.extraPackages32 = with pkgs.pkgsi686Linux; [ libva ]; environment.systemPackages = with pkgs; [ steam-tui