dot
vizie's NixOS desktop: Hyprland, CachyOS kernel and gaming tweaks
| 1 | # RTX 3080 Ti with the open kernel module, as linux-cachyos-nvidia-open on |
| 2 | # CachyOS. Turned off in the test VM (see vm.nix). |
| 3 | { |
| 4 | config, |
| 5 | lib, |
| 6 | pkgs, |
| 7 | ... |
| 8 | }: |
| 9 | let |
| 10 | cfg = config.dot.nvidia; |
| 11 | |
| 12 | # The driver CachyOS runs: 615.78.08. The kernel's package set comes from the |
| 13 | # nixpkgs the CachyOS kernel flake pins (cachyos.nix), which can be a driver |
| 14 | # release behind the system's nixpkgs. Then the driver is built from the |
| 15 | # system nixpkgs' definition instead (pkgs/os-specific/linux/nvidia-x11), |
| 16 | # against the same kernel. Once the pinned set catches up, its own driver is |
| 17 | # used again and this can go. |
| 18 | pinnedDriver = config.boot.kernelPackages.nvidiaPackages.latest; |
| 19 | nvidiaDriver = |
| 20 | if lib.versionAtLeast pinnedDriver.version "615.78.08" then |
| 21 | pinnedDriver |
| 22 | else |
| 23 | config.boot.kernelPackages.nvidiaPackages.mkDriver { |
| 24 | version = "615.78.08"; |
| 25 | sha256_64bit = "sha256-Pj9t3cLudnoIGFMAr3vjyyhuznZpjS3eNSRZl4LQf/4="; |
| 26 | sha256_aarch64 = "sha256-UHYBE1AYHoGgMfD9AS/jX+S+N8eCDWUft6qolK9Eejc="; |
| 27 | openSha256 = "sha256-HBINiOjL0ZJLIAJeNIBYHBnwgUXtNwPPtnFpAI1YwF4="; |
| 28 | settingsSha256 = "sha256-inDRpG02sdDgHmlqgu/DsgK8OFdOt1fZIYyXdhlGC/c="; |
| 29 | persistencedSha256 = "sha256-RzeR6Ldct6MUxjnXRyThdh5Y3jjMehTVg85MtwuWNX4="; |
| 30 | }; |
| 31 | in |
| 32 | { |
| 33 | options.dot.nvidia.enable = lib.mkEnableOption "the NVIDIA driver" // { |
| 34 | default = true; |
| 35 | }; |
| 36 | |
| 37 | config = lib.mkMerge [ |
| 38 | { |
| 39 | hardware.graphics = { |
| 40 | enable = true; |
| 41 | enable32Bit = true; |
| 42 | }; |
| 43 | } |
| 44 | |
| 45 | (lib.mkIf cfg.enable { |
| 46 | services.xserver.videoDrivers = [ "nvidia" ]; |
| 47 | |
| 48 | hardware.nvidia = { |
| 49 | open = true; |
| 50 | package = nvidiaDriver; |
| 51 | modesetting.enable = true; |
| 52 | nvidiaSettings = true; |
| 53 | # Not set up on CachyOS either (no nvidia-suspend services enabled). |
| 54 | powerManagement.enable = false; |
| 55 | }; |
| 56 | |
| 57 | # libva-nvidia-driver: Firefox hardware video decoding (see the NVD_BACKEND |
| 58 | # and LIBVA_DRIVER_NAME lines in hyprland.lua). |
| 59 | hardware.graphics.extraPackages = [ pkgs.nvidia-vaapi-driver ]; |
| 60 | }) |
| 61 | ]; |
| 62 | } |