nixos-configs/nixosModules/nvidia/default.nix

91 lines
1.9 KiB
Nix
Raw Normal View History

{
config,
lib,
pkgs,
...
}: let
2024-06-24 12:30:49 -04:00
inherit (lib) mkIf mkEnableOption mkOption optionals types;
cfg = config.nvidia;
in {
options.nvidia = {
2024-06-24 12:30:49 -04:00
enable = mkEnableOption "nvidia";
enableNvidiaSettings = mkOption {
type = types.bool;
default = false;
};
enableWayland = mkOption {
type = types.bool;
default = false;
};
enableCUDA = mkOption {
type = types.bool;
default = false;
};
};
config = mkIf cfg.enable {
2024-06-21 18:15:19 -04:00
hardware.graphics = {
enable = true;
2024-06-21 18:15:19 -04:00
enable32Bit = true;
extraPackages = with pkgs; [
vaapiVdpau
libvdpau-va-gl
nvidia-vaapi-driver
];
extraPackages32 = with pkgs; [vaapiVdpau];
};
services.xserver.videoDrivers = ["nvidia"];
hardware.nvidia = {
modesetting.enable = true;
# Enable the Nvidia settings menu,
# accessible via `nvidia-settings`.
nvidiaSettings = cfg.enableNvidiaSettings;
# Nvidia power management. Experimental, and can cause sleep/suspend to fail.
powerManagement = {
enable = false;
# Fine-grained power management. Turns off GPU when not in use.
# Experimental and only works on modern Nvidia GPUs (Turing or newer).
finegrained = false;
};
open = false;
chore: update flake.lock Flake Inputs: • Updated input 'caddy-plugins': 'github:matt1432/nixos-caddy-cloudflare/3e6819b' (2024-07-04) → 'github:matt1432/nixos-caddy-cloudflare/f2a856f' (2024-07-30) • Updated input 'discord-overlay': 'github:matt1432/discord-nightly-overlay/4df152b' (2024-07-29) → 'github:matt1432/discord-nightly-overlay/a9c387d' (2024-07-30) • Updated input 'home-manager': 'github:nix-community/home-manager/89670e2' (2024-07-29) → 'github:nix-community/home-manager/4fcd54d' (2024-07-30) • Updated input 'hyprland': 'git+https://github.com/hyprwm/Hyprland?ref=refs/heads/main&rev=e673220&submodules=1' (2024-07-29) → 'git+https://github.com/hyprwm/Hyprland?ref=refs/heads/main&rev=3b9b534&submodules=1' (2024-07-30) • Updated input 'hyprland/aquamarine': 'github:hyprwm/aquamarine/4918e57' (2024-07-27) → 'github:hyprwm/aquamarine/7c3565f' (2024-07-30) • Updated input 'hyprland/xdph': 'github:hyprwm/xdg-desktop-portal-hyprland/0e2f3b9' (2024-07-28) → 'github:hyprwm/xdg-desktop-portal-hyprland/7f2a77d' (2024-07-30) • Updated input 'jellyfin-flake': 'github:matt1432/nixos-jellyfin/4b8f983' (2024-07-26) → 'github:matt1432/nixos-jellyfin/7253d43' (2024-07-30) • Updated input 'khepri': 'github:matt1432/khepri/52d9b7e' (2024-07-24) → 'github:matt1432/khepri/a7d1a51' (2024-07-30) • Updated input 'minix': 'github:matt1432/Minix/7537fb8' (2024-07-13) → 'github:matt1432/Minix/d3f8c44' (2024-07-30) • Updated input 'nixpkgs': 'github:NixOS/nixpkgs/b73c222' (2024-07-27) → 'github:NixOS/nixpkgs/3fcada1' (2024-07-30) • Updated input 'nixpkgs-wayland': 'github:nix-community/nixpkgs-wayland/6642ef6' (2024-07-28) → 'github:nix-community/nixpkgs-wayland/8badd76' (2024-07-30) • Updated input 'pcsd': 'github:matt1432/nixos-pcsd/62b44c2' (2024-07-27) → 'github:matt1432/nixos-pcsd/3fa8578' (2024-07-30) • Updated input 'pr-tracker': 'github:matt1432/pr-tracker/c0df731' (2024-07-30) → 'github:matt1432/pr-tracker/8e93c30' (2024-07-30) Docker Images: • codeberg.org/forgejo/forgejo 8.0.0: sha256:6f4620d8fb4bb8288315b07ca65286da958745d623fc9eaef4bb4e0e34c68b3d → sha256:f3ec5c63038cf2ce31a71e50e48b24c334ba0a5233808d1a5a60d45203f84f02 • rssbridge/rss-bridge latest: sha256:5d8906da7276396e077e054eb7e646f4f02d639be60a0b3bded97ec751fc0700 → sha256:6161fe1fef70ad077dcae364164d7739c9c0d76bbc7f154dd64a2352fc93f291 • ghcr.io/immich-app/immich-machine-learning v1.111.0: sha256:794c3fc4a1da9925f1fdd4ac13fd0646f11a5f682bd50e1cd7e2283f3332ac65 → sha256:d4a5db2c7cda2897abea98a3d5fd0c3cc76618fff271708075faeee426fe1b64 • ghcr.io/immich-app/immich-server v1.111.0: sha256:9de91632ea5c0aabcd5558cab8b270f6bde00679fc6bdc35806fb49367e4a583 → sha256:14ad5881f5afbea1dbf751e14acaafe00e6b012ffb18a56e9f117b00eb067d1d • ghcr.io/linuxserver/bazarr latest: sha256:25f0d19ba9226fdf15aec0fc7fa134ba89fc6f77f09d7bd45b33c5960c47821e → sha256:e70de8a714ac57395d45052392001ec433b8f48aa1c204f13dae312cbcbe43af Firefox Addons: bitwarden: 2024.6.3 -> 2024.7.1
2024-07-30 22:21:08 -04:00
package = let
inherit (config.boot.kernelPackages.nvidiaPackages) stable beta;
in
if !cfg.enableWayland
chore: update flake.lock Flake Inputs: • Updated input 'caddy-plugins': 'github:matt1432/nixos-caddy-cloudflare/3e6819b' (2024-07-04) → 'github:matt1432/nixos-caddy-cloudflare/f2a856f' (2024-07-30) • Updated input 'discord-overlay': 'github:matt1432/discord-nightly-overlay/4df152b' (2024-07-29) → 'github:matt1432/discord-nightly-overlay/a9c387d' (2024-07-30) • Updated input 'home-manager': 'github:nix-community/home-manager/89670e2' (2024-07-29) → 'github:nix-community/home-manager/4fcd54d' (2024-07-30) • Updated input 'hyprland': 'git+https://github.com/hyprwm/Hyprland?ref=refs/heads/main&rev=e673220&submodules=1' (2024-07-29) → 'git+https://github.com/hyprwm/Hyprland?ref=refs/heads/main&rev=3b9b534&submodules=1' (2024-07-30) • Updated input 'hyprland/aquamarine': 'github:hyprwm/aquamarine/4918e57' (2024-07-27) → 'github:hyprwm/aquamarine/7c3565f' (2024-07-30) • Updated input 'hyprland/xdph': 'github:hyprwm/xdg-desktop-portal-hyprland/0e2f3b9' (2024-07-28) → 'github:hyprwm/xdg-desktop-portal-hyprland/7f2a77d' (2024-07-30) • Updated input 'jellyfin-flake': 'github:matt1432/nixos-jellyfin/4b8f983' (2024-07-26) → 'github:matt1432/nixos-jellyfin/7253d43' (2024-07-30) • Updated input 'khepri': 'github:matt1432/khepri/52d9b7e' (2024-07-24) → 'github:matt1432/khepri/a7d1a51' (2024-07-30) • Updated input 'minix': 'github:matt1432/Minix/7537fb8' (2024-07-13) → 'github:matt1432/Minix/d3f8c44' (2024-07-30) • Updated input 'nixpkgs': 'github:NixOS/nixpkgs/b73c222' (2024-07-27) → 'github:NixOS/nixpkgs/3fcada1' (2024-07-30) • Updated input 'nixpkgs-wayland': 'github:nix-community/nixpkgs-wayland/6642ef6' (2024-07-28) → 'github:nix-community/nixpkgs-wayland/8badd76' (2024-07-30) • Updated input 'pcsd': 'github:matt1432/nixos-pcsd/62b44c2' (2024-07-27) → 'github:matt1432/nixos-pcsd/3fa8578' (2024-07-30) • Updated input 'pr-tracker': 'github:matt1432/pr-tracker/c0df731' (2024-07-30) → 'github:matt1432/pr-tracker/8e93c30' (2024-07-30) Docker Images: • codeberg.org/forgejo/forgejo 8.0.0: sha256:6f4620d8fb4bb8288315b07ca65286da958745d623fc9eaef4bb4e0e34c68b3d → sha256:f3ec5c63038cf2ce31a71e50e48b24c334ba0a5233808d1a5a60d45203f84f02 • rssbridge/rss-bridge latest: sha256:5d8906da7276396e077e054eb7e646f4f02d639be60a0b3bded97ec751fc0700 → sha256:6161fe1fef70ad077dcae364164d7739c9c0d76bbc7f154dd64a2352fc93f291 • ghcr.io/immich-app/immich-machine-learning v1.111.0: sha256:794c3fc4a1da9925f1fdd4ac13fd0646f11a5f682bd50e1cd7e2283f3332ac65 → sha256:d4a5db2c7cda2897abea98a3d5fd0c3cc76618fff271708075faeee426fe1b64 • ghcr.io/immich-app/immich-server v1.111.0: sha256:9de91632ea5c0aabcd5558cab8b270f6bde00679fc6bdc35806fb49367e4a583 → sha256:14ad5881f5afbea1dbf751e14acaafe00e6b012ffb18a56e9f117b00eb067d1d • ghcr.io/linuxserver/bazarr latest: sha256:25f0d19ba9226fdf15aec0fc7fa134ba89fc6f77f09d7bd45b33c5960c47821e → sha256:e70de8a714ac57395d45052392001ec433b8f48aa1c204f13dae312cbcbe43af Firefox Addons: bitwarden: 2024.6.3 -> 2024.7.1
2024-07-30 22:21:08 -04:00
then stable
2024-05-22 10:24:21 -04:00
else
# Get newest beta driver version for better Wayland support
chore: update flake.lock Flake Inputs: • Updated input 'caddy-plugins': 'github:matt1432/nixos-caddy-cloudflare/3e6819b' (2024-07-04) → 'github:matt1432/nixos-caddy-cloudflare/f2a856f' (2024-07-30) • Updated input 'discord-overlay': 'github:matt1432/discord-nightly-overlay/4df152b' (2024-07-29) → 'github:matt1432/discord-nightly-overlay/a9c387d' (2024-07-30) • Updated input 'home-manager': 'github:nix-community/home-manager/89670e2' (2024-07-29) → 'github:nix-community/home-manager/4fcd54d' (2024-07-30) • Updated input 'hyprland': 'git+https://github.com/hyprwm/Hyprland?ref=refs/heads/main&rev=e673220&submodules=1' (2024-07-29) → 'git+https://github.com/hyprwm/Hyprland?ref=refs/heads/main&rev=3b9b534&submodules=1' (2024-07-30) • Updated input 'hyprland/aquamarine': 'github:hyprwm/aquamarine/4918e57' (2024-07-27) → 'github:hyprwm/aquamarine/7c3565f' (2024-07-30) • Updated input 'hyprland/xdph': 'github:hyprwm/xdg-desktop-portal-hyprland/0e2f3b9' (2024-07-28) → 'github:hyprwm/xdg-desktop-portal-hyprland/7f2a77d' (2024-07-30) • Updated input 'jellyfin-flake': 'github:matt1432/nixos-jellyfin/4b8f983' (2024-07-26) → 'github:matt1432/nixos-jellyfin/7253d43' (2024-07-30) • Updated input 'khepri': 'github:matt1432/khepri/52d9b7e' (2024-07-24) → 'github:matt1432/khepri/a7d1a51' (2024-07-30) • Updated input 'minix': 'github:matt1432/Minix/7537fb8' (2024-07-13) → 'github:matt1432/Minix/d3f8c44' (2024-07-30) • Updated input 'nixpkgs': 'github:NixOS/nixpkgs/b73c222' (2024-07-27) → 'github:NixOS/nixpkgs/3fcada1' (2024-07-30) • Updated input 'nixpkgs-wayland': 'github:nix-community/nixpkgs-wayland/6642ef6' (2024-07-28) → 'github:nix-community/nixpkgs-wayland/8badd76' (2024-07-30) • Updated input 'pcsd': 'github:matt1432/nixos-pcsd/62b44c2' (2024-07-27) → 'github:matt1432/nixos-pcsd/3fa8578' (2024-07-30) • Updated input 'pr-tracker': 'github:matt1432/pr-tracker/c0df731' (2024-07-30) → 'github:matt1432/pr-tracker/8e93c30' (2024-07-30) Docker Images: • codeberg.org/forgejo/forgejo 8.0.0: sha256:6f4620d8fb4bb8288315b07ca65286da958745d623fc9eaef4bb4e0e34c68b3d → sha256:f3ec5c63038cf2ce31a71e50e48b24c334ba0a5233808d1a5a60d45203f84f02 • rssbridge/rss-bridge latest: sha256:5d8906da7276396e077e054eb7e646f4f02d639be60a0b3bded97ec751fc0700 → sha256:6161fe1fef70ad077dcae364164d7739c9c0d76bbc7f154dd64a2352fc93f291 • ghcr.io/immich-app/immich-machine-learning v1.111.0: sha256:794c3fc4a1da9925f1fdd4ac13fd0646f11a5f682bd50e1cd7e2283f3332ac65 → sha256:d4a5db2c7cda2897abea98a3d5fd0c3cc76618fff271708075faeee426fe1b64 • ghcr.io/immich-app/immich-server v1.111.0: sha256:9de91632ea5c0aabcd5558cab8b270f6bde00679fc6bdc35806fb49367e4a583 → sha256:14ad5881f5afbea1dbf751e14acaafe00e6b012ffb18a56e9f117b00eb067d1d • ghcr.io/linuxserver/bazarr latest: sha256:25f0d19ba9226fdf15aec0fc7fa134ba89fc6f77f09d7bd45b33c5960c47821e → sha256:e70de8a714ac57395d45052392001ec433b8f48aa1c204f13dae312cbcbe43af Firefox Addons: bitwarden: 2024.6.3 -> 2024.7.1
2024-07-30 22:21:08 -04:00
beta;
};
2024-05-05 23:07:06 -04:00
environment.systemPackages =
optionals cfg.enableCUDA [pkgs.cudaPackages.cudatoolkit]
++ (with pkgs; [
libva-utils
nvidia-vaapi-driver
2024-03-22 21:10:11 -04:00
nvtopPackages.nvidia
pciutils
vdpauinfo
2024-05-05 23:07:06 -04:00
]);
boot.kernelModules =
optionals cfg.enableCUDA ["nvidia-uvm"]
++ ["nvidia" "nvidia-drm"];
};
# For accurate stack trace
_file = ./default.nix;
}