This commit is contained in:
Peder Bergebakken Sundt 2023-06-18 23:36:17 +02:00
parent 35878bd92a
commit 280c9c69d0
4 changed files with 51 additions and 2 deletions

View File

@ -104,7 +104,7 @@
noximilien = mkConfig "noximilien" "x86_64-linux" (with nm; [ common-pc common-pc-ssd common-cpu-intel ]);
bolle = mkConfig "bolle" "x86_64-linux" (with nm; [ common-pc common-pc-ssd common-cpu-intel ]);
nord = mkConfig "nord" "x86_64-linux" (with nm; [ common-pc common-pc-ssd common-cpu-intel-cpu-only common-gpu-amd ]);
sopp = mkConfig "sopp" "x86_64-linux" (with nm; [ common-pc common-pc-ssd common-cpu-intel ]); # TODO: common-gpu-nvidia
sopp = mkConfig "sopp" "x86_64-linux" (with nm; [ common-pc common-pc-ssd common-cpu-intel-cpu-only common-gpu-nvidia-nonprime ]);
};
homeConfigurations = forAllSystems (system: let

48
hardware/cuda.nix Normal file
View File

@ -0,0 +1,48 @@
{ config, pkgs, lib, ... }:
{
# assumes common-gpu-nvidia from nixos-hardware is also added
# TODO: should we move it from flake.nix to here?
# https://nixos.wiki/wiki/Nvidia
nixpkgs.config.cudaSupport = true;
nixpkgs.config.allowUnfreePredicate = pkg: lib.any (x: x) [
(lib.hasInfix "nvidia" (lib.toLower (lib.getName pkg)))
(lib.hasInfix "cuda" (lib.toLower (lib.getName pkg)))
(lib.hasInfix "cudnn" (lib.toLower (lib.getName pkg)))
(lib.hasInfix "cublas" (lib.toLower (lib.getName pkg)))
];
hardware.opengl.enable = true;
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.stable;
hardware.nvidia.modesetting.enable = true;
# add this to the host in question:
#hardware.nvidia.prime = {
# offload.enable = true;
# # Bus IDs. You can find them using lspci, grepping for "3D" or "VGA"
# intelBusId = "PCI:0:2:0";
# nvidiaBusId = "PCI:1:0:0";
#};
environment.systemPackages = with pkgs; ([
nvtop
] ++ lib.optional hardware.nvidia.prime.offload.enable [
(writeShellScriptBin "prime-run" ''
export __NV_PRIME_RENDER_OFFLOAD=1
export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0
export __GLX_VENDOR_LIBRARY_NAME=nvidia
export __VK_LAYER_NV_optimus=NVIDIA_only
exec "$@"
'')
# already added by nixos-hardware.common-gpu-nvidia
#(writeShellScriptBin "nvidia-offload" ''
# export __NV_PRIME_RENDER_OFFLOAD=1
# export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0
# export __GLX_VENDOR_LIBRARY_NAME=nvidia
# export __VK_LAYER_NV_optimus=NVIDIA_only
# exec "$@"
#'')
]);
}

View File

@ -5,6 +5,7 @@
# https://libreddit.noximilien.pbsds.net/r/archlinux/comments/nih9c9/amdgpu_vs_modesetting_in_current_510_kernels_xorg/
hardware.opengl.enable = true;
services.xserver.videoDrivers = [ "amdgpu" ]; # use gpu, adaptive sync and and hardware page flipping
#services.xserver.videoDrivers = [ "modesetting" ]; # integrated (non-accelerated) framebuffer, KMS

View File

@ -14,7 +14,7 @@
imports = [
./hardware-configuration.nix
#../../hardware/rocm.nix # TODO: CUDA
../../hardware/cuda.nix
../../hardware/opengl-intel.nix
../../users # home-manager