From 7123e47119b0b145bb27e557815cf1c841f60ee9 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Sat, 2 Mar 2024 23:36:07 -0500 Subject: [PATCH] feat(servers): make use of nvidia gpu for jellyfin --- devices/nos/hardware-configuration.nix | 40 ++++++++++++++++++++++- devices/nos/modules/jellyfin/packages.nix | 21 ++++++++---- 2 files changed, 54 insertions(+), 7 deletions(-) diff --git a/devices/nos/hardware-configuration.nix b/devices/nos/hardware-configuration.nix index 2c575a18..e95ff252 100644 --- a/devices/nos/hardware-configuration.nix +++ b/devices/nos/hardware-configuration.nix @@ -1,13 +1,14 @@ { config, modulesPath, + pkgs, ... }: { nixpkgs.hostPlatform = "x86_64-linux"; imports = [(modulesPath + "/installer/scan/not-detected.nix")]; boot = { - kernelModules = ["kvm-intel"]; + kernelModules = ["kvm-intel" "nvidia-uvm"]; initrd.availableKernelModules = [ "xhci_pci" @@ -45,4 +46,41 @@ zramSwap.enable = true; hardware.cpu.intel.updateMicrocode = config.hardware.enableRedistributableFirmware; + + # NVIDIA settings + services.xserver.videoDrivers = ["nvidia"]; + + hardware.opengl = { + enable = true; + driSupport = true; + driSupport32Bit = true; + + extraPackages = with pkgs; [ + vaapiVdpau + libvdpau-va-gl + nvidia-vaapi-driver + ]; + extraPackages32 = with pkgs; [vaapiVdpau]; + }; + + hardware.nvidia = { + modesetting.enable = true; + + powerManagement.enable = false; + powerManagement.finegrained = false; + open = false; + nvidiaSettings = false; + + # Vulkan is much more stable in Wayland + package = config.boot.kernelPackages.nvidiaPackages.stable; + }; + + environment.systemPackages = with pkgs; [ + libva-utils + nvidia-vaapi-driver + nvtop-nvidia + pciutils + vdpauinfo + cudaPackages.cudatoolkit + ]; } diff --git a/devices/nos/modules/jellyfin/packages.nix b/devices/nos/modules/jellyfin/packages.nix index 66a56c4d..7009a0bc 100644 --- a/devices/nos/modules/jellyfin/packages.nix +++ b/devices/nos/modules/jellyfin/packages.nix @@ -1,15 +1,24 @@ { - pkgs, + config, lib, + pkgs, ... }: let inherit (lib) hasAttr optionals; -in { - environment.systemPackages = [ - pkgs.jellyfin - pkgs.jellyfin-ffmpeg - (pkgs.jellyfin-web.overrideAttrs (_: o: { + isNvidia = config.hardware.nvidia.modesetting.enable; + jellyPkgs = + if isNvidia + then pkgs.cudaPackages.pkgs + else pkgs; +in { + services.jellyfin.package = jellyPkgs.jellyfin; + + environment.systemPackages = [ + jellyPkgs.jellyfin + jellyPkgs.jellyfin-ffmpeg + + (jellyPkgs.jellyfin-web.overrideAttrs (_: o: { patches = [ (pkgs.fetchpatch {