diff --git a/hosts/yhwach/configuration.nix b/hosts/yhwach/configuration.nix index f5dd7df..cff5ab4 100644 --- a/hosts/yhwach/configuration.nix +++ b/hosts/yhwach/configuration.nix @@ -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 @@ -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 - # ]; - }; - }; } diff --git a/modules/nixos/environment/default.nix b/modules/nixos/environment/default.nix index 1bc37e1..b71d9a5 100644 --- a/modules/nixos/environment/default.nix +++ b/modules/nixos/environment/default.nix @@ -15,6 +15,7 @@ ./amd ./intel.nix + ./nvidia.nix ]; cachix.enable = lib.mkDefault false; @@ -24,4 +25,5 @@ amd.enable = lib.mkDefault false; intel.enable = lib.mkDefault false; + nvidia.enable = lib.mkDefault false; } diff --git a/modules/nixos/environment/nvidia/default.nix b/modules/nixos/environment/nvidia/default.nix new file mode 100644 index 0000000..5e3488b --- /dev/null +++ b/modules/nixos/environment/nvidia/default.nix @@ -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; + }; + }; + }; +}