Skip to content

Commit

Permalink
Move nvidia config to separate module and add to yhwach
Browse files Browse the repository at this point in the history
  • Loading branch information
arunoruto committed Oct 21, 2024
1 parent b9696f9 commit bcc4668
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 75 deletions.
76 changes: 1 addition & 75 deletions hosts/yhwach/configuration.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
{
pkgs,
lib,
config,
...
}: {
# Set hostname
networking.hostName = lib.mkForce "yhwach"; # Define your hostname.
nvidia.enable = true;
netbird.enable = true;

# Enable lanzaboote for secure-boot
Expand All @@ -24,72 +18,4 @@

# Eanble fingerprint for framework laptop
# fingerprint.enable = true;

# Load nvidia driver for Xorg and Wayland
services.xserver.videoDrivers = ["nvidia"];

hardware = {
nvidia = {
# Modesetting is required.
modesetting.enable = true;

# Nvidia power management. Experimental, and can cause sleep/suspend to fail.
# Enable this if you have graphical corruption issues or application crashes after waking
# up from sleep. This fixes it by saving the entire VRAM memory to /tmp/ instead
# of just the bare essentials.
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).
powerManagement.finegrained = false;

# Use the NVidia open source kernel module (not to be confused with the
# independent third-party "nouveau" open source driver).
# Support is limited to the Turing and later architectures. Full list of
# supported GPUs is at:
# https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus
# Only available from driver 515.43.04+
# Currently alpha-quality/buggy, so false is currently the recommended setting.
open = false;

# Enable the Nvidia settings menu,
# accessible via `nvidia-settings`.
nvidiaSettings = true;

# package = config.boot.kernelPackages.nvidiaPackages.beta;
# package = config.boot.kernelPackages.nvidiaPackages.production;
# package = config.boot.kernelPackages.nvidiaPackages.stable;
package = config.boot.kernelPackages.nvidiaPackages.mkDriver {
version = "555.58.02";
sha256_64bit = "sha256-xctt4TPRlOJ6r5S54h5W6PT6/3Zy2R4ASNFPu8TSHKM=";
sha256_aarch64 = "sha256-wb20isMrRg8PeQBU96lWJzBMkjfySAUaqt4EgZnhyF8=";
openSha256 = "sha256-8hyRiGB+m2hL3c9MDA/Pon+Xl6E788MZ50WrrAGUVuY=";
settingsSha256 = "sha256-ZpuVZybW6CFN/gz9rx+UJvQ715FZnAOYfHn5jt5Z2C8=";
persistencedSha256 = "sha256-a1D7ZZmcKFWfPjjH1REqPM5j/YLWKnbkP9qfRyIyxAw=";
};
# package = config.boot.kernelPackages.nvidiaPackages.mkDriver {
# version = "560.35.03";
# sha256_64bit = "sha256-8pMskvrdQ8WyNBvkU/xPc/CtcYXCa7ekP73oGuKfH+M=";
# sha256_aarch64 = "sha256-s8ZAVKvRNXpjxRYqM3E5oss5FdqW+tv1qQC2pDjfG+s=";
# openSha256 = "sha256-/32Zf0dKrofTmPZ3Ratw4vDM7B+OgpC4p7s+RHUjCrg=";
# settingsSha256 = "sha256-kQsvDgnxis9ANFmwIwB7HX5MkIAcpEEAHc8IBOLdXvk=";
# persistencedSha256 = "sha256-E2J2wYYyRu7Kc3MMZz/8ZIemcZg68rkzvqEwFAL3fFs=";
# };
};
opengl = {
enable = true;
# # package = pkgs.unstable.mesa.drivers;
# extraPackages = with pkgs; [
# intel-compute-runtime
# intel-ocl
# intel-media-driver # LIBVA_DRIVER_NAME=iHD
# intel-vaapi-driver # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium)
# vaapiVdpau
# libvdpau-va-gl
# # https://nixos.wiki/wiki/Intel_Graphics
# unstable.vpl-gpu-rt
# intel-media-sdk
# ];
};
};
}
2 changes: 2 additions & 0 deletions modules/nixos/environment/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

./amd
./intel.nix
./nvidia.nix
];

cachix.enable = lib.mkDefault false;
Expand All @@ -24,4 +25,5 @@

amd.enable = lib.mkDefault false;
intel.enable = lib.mkDefault false;
nvidia.enable = lib.mkDefault false;
}
70 changes: 70 additions & 0 deletions modules/nixos/environment/nvidia/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
pkgs,
lib,
config,
...
}: {
options.nvidia.enable = lib.mkEnableOption "Setup Nvidia environment";

config = lib.mkIf config.nvidia.enable {
# boot = {
# kernelParams = ["nvidia.NVreg_EnableGpuFirmware=0"];
# };

# Load nvidia driver for Xorg and Wayland
services.xserver.videoDrivers = lib.mkDefault ["nvidia"];

hardware = {
nvidia = {
# Modesetting is required.
modesetting.enable = true;

# Nvidia power management. Experimental, and can cause sleep/suspend to fail.
# Enable this if you have graphical corruption issues or application crashes after waking
# up from sleep. This fixes it by saving the entire VRAM memory to /tmp/ instead
# of just the bare essentials.
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).
powerManagement.finegrained = false;

# Use the NVidia open source kernel module (not to be confused with the
# independent third-party "nouveau" open source driver).
# Support is limited to the Turing and later architectures. Full list of
# supported GPUs is at:
# https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus
# Only available from driver 515.43.04+
# Currently alpha-quality/buggy, so false is currently the recommended setting.
open = false;

# Enable the Nvidia settings menu,
# accessible via `nvidia-settings`.
nvidiaSettings = true;

# package = config.boot.kernelPackages.nvidiaPackages.beta;
# package = config.boot.kernelPackages.nvidiaPackages.production;
# package = config.boot.kernelPackages.nvidiaPackages.stable;
package = config.boot.kernelPackages.nvidiaPackages.mkDriver {
version = "555.58.02";
sha256_64bit = "sha256-xctt4TPRlOJ6r5S54h5W6PT6/3Zy2R4ASNFPu8TSHKM=";
sha256_aarch64 = "sha256-wb20isMrRg8PeQBU96lWJzBMkjfySAUaqt4EgZnhyF8=";
openSha256 = "sha256-8hyRiGB+m2hL3c9MDA/Pon+Xl6E788MZ50WrrAGUVuY=";
settingsSha256 = "sha256-ZpuVZybW6CFN/gz9rx+UJvQ715FZnAOYfHn5jt5Z2C8=";
persistencedSha256 = "sha256-a1D7ZZmcKFWfPjjH1REqPM5j/YLWKnbkP9qfRyIyxAw=";
};
# package = config.boot.kernelPackages.nvidiaPackages.mkDriver {
# version = "560.35.03";
# sha256_64bit = "sha256-8pMskvrdQ8WyNBvkU/xPc/CtcYXCa7ekP73oGuKfH+M=";
# sha256_aarch64 = "sha256-s8ZAVKvRNXpjxRYqM3E5oss5FdqW+tv1qQC2pDjfG+s=";
# openSha256 = "sha256-/32Zf0dKrofTmPZ3Ratw4vDM7B+OgpC4p7s+RHUjCrg=";
# settingsSha256 = "sha256-kQsvDgnxis9ANFmwIwB7HX5MkIAcpEEAHc8IBOLdXvk=";
# persistencedSha256 = "sha256-E2J2wYYyRu7Kc3MMZz/8ZIemcZg68rkzvqEwFAL3fFs=";
# };
};
opengl = {
enable = true;
};
};
};
}

0 comments on commit bcc4668

Please sign in to comment.