added config for nvidia/intel gpus and settings file

This commit is contained in:
Sven Vogel 2023-12-15 18:31:08 +01:00
parent ffaac68fa6
commit 88b1681dcb
5 changed files with 52 additions and 4 deletions

View File

@ -1,8 +1,14 @@
{ pkgs, config, ... }: {
{ pkgs, lib, ... }:
{
# Adapted from: https://github.com/NixOS/nixos-hardware/blob/master/common/gpu/amd/default.nix
# Make the kernel use the correct driver early
boot.initrd.kernelModules = [ "amdgpu" ];
# Make sure Xserver uses the `amdgpu` driver
services.xserver.enable = true;
services.xserver.videoDrivers = [ "amdgpu" ];
# For 32 bit applications
hardware.opengl.driSupport32Bit = true;
@ -12,6 +18,11 @@
rocmPackages.clr.icd
];
# For 32 bit applications
hardware.opengl.extraPackages32 = with pkgs; [
driversi686Linux.amdvlk
];
environment.systemPackages = with pkgs; [
nvtop-amd
clinfo

View File

@ -1,5 +1,11 @@
{ lib, ... }:
let
settings = import ./../settings.nix;
in
{
imports = [
./amdgpu.nix
];
# Optionally import modules for specific hardware
imports =
lib.optionals settings.hardware.amdgpu [ ./amdgpu.nix ]
++ lib.optionals settings.hardware.intelgpu [ ./intelgpu.nix ]
++ lib.optionals settings.hardware.nvidiagpu [ ./nvidiagpu.nix ];
}

16
hardware/intelgpu.nix Normal file
View File

@ -0,0 +1,16 @@
{ pkgs, lib, ... }:
{
# Excerpt: https://github.com/NixOS/nixos-hardware/blob/master/common/gpu/intel/default.nix
boot.initrd.kernelModules = [ "i915" ];
environment.variables = {
VDPAU_DRIVER = lib.mkIf config.hardware.opengl.enable (lib.mkDefault "va_gl");
};
hardware.opengl.extraPackages = with pkgs; [
(if (lib.versionOlder (lib.versions.majorMinor lib.version) "23.11") then vaapiIntel else intel-vaapi-driver)
libvdpau-va-gl
intel-media-driver
];
}

8
hardware/nvidia.nix Normal file
View File

@ -0,0 +1,8 @@
{ pkgs, lib, ... }:
{
# Excerpt from: https://github.com/NixOS/nixos-hardware/blob/master/common/gpu/nvidia/default.nix
services.xserver.videoDrivers = lib.mkDefault [ "nvidia" ];
hardware.opengl.extraPackages = with pkgs; [
vaapiVdpau
];
}

7
settings.nix Normal file
View File

@ -0,0 +1,7 @@
{
hardware = {
amdgpu = true;
intelgpu = false;
nvidiagpu = false;
};
}