From 083d67c1dfeca2d0f85121f8b06cb664b61fe2bb Mon Sep 17 00:00:00 2001 From: rafiq Date: Thu, 27 Feb 2025 07:51:44 +0800 Subject: [PATCH] feat(nvidia): add proper nvidia drivers --- hosts/nemesis/default.nix | 37 +++++++++++++++++++++++++++++++-- scripts/hyprland-tty-launch.nix | 20 ++++++++++++++++++ users/rafiq/default.nix | 9 ++++++++ 3 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 scripts/hyprland-tty-launch.nix diff --git a/hosts/nemesis/default.nix b/hosts/nemesis/default.nix index c58143f..e2192f6 100644 --- a/hosts/nemesis/default.nix +++ b/hosts/nemesis/default.nix @@ -8,18 +8,50 @@ imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix + ../../scripts/hyprland-tty-launch.nix ]; # Bootloader. boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; + # Graphics settings are defined here + hardware = { + graphics.enable = true; + graphics.extraPackages = with pkgs; [ + nvidia-vaapi-driver + ocl-icd + cudaPackages.cudatoolkit + # clinfo + ]; + nvidia = { + open = true; + package = config.boot.kernelPackages.nvidiaPackages.stable; + }; + }; + + services.xserver = { + enable = true; + videoDrivers = [ "nvidia" ]; + }; + # Add hyprland.cachix.org as a binary cache for Hyprland nix.settings = { - substituters = ["https://hyprland.cachix.org"]; - trusted-public-keys = ["hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="]; + substituters = [ + "https://hyprland.cachix.org" + "https://cuda-maintainers.cachix.org" + "https://nix-community.cachix.org" + ]; + trusted-public-keys = [ + "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" + "cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E=" + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + ]; }; + # Scripts + services.hyprland-tty-launch.enable = true; + networking.hostName = "nemesis"; # Define your hostname. # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. @@ -68,6 +100,7 @@ # $ nix search wget environment.systemPackages = with pkgs; [ firefox + clinfo ]; # Some programs need SUID wrappers, can be configured further or are diff --git a/scripts/hyprland-tty-launch.nix b/scripts/hyprland-tty-launch.nix new file mode 100644 index 0000000..2f237e5 --- /dev/null +++ b/scripts/hyprland-tty-launch.nix @@ -0,0 +1,20 @@ +{ config, lib, ... }: + +{ + options.services.hyprland-tty-launch.enable = lib.mkEnableOption "Enable launching Hyprland from TTY with UWSM"; + + config = lib.mkIf config.services.hyprland-tty-launch.enable { + environment.etc."profile.d/hyprland-tty-launch.sh".text = '' + #!/bin/$SHELL + + # if uwsm check may-start && uwsm select; then + # exec systemd-cat -t uwsm_start uwsm start default + # fi + + # OR (to bypass the compositor selection menu): + if uwsm check may-start; then + exec uwsm start hyprland.desktop + fi + ''; + }; +} diff --git a/users/rafiq/default.nix b/users/rafiq/default.nix index c97734e..e2b358b 100644 --- a/users/rafiq/default.nix +++ b/users/rafiq/default.nix @@ -8,6 +8,15 @@ self.packages.${pkgs.stdenv.system}.nvf pkgs.kitty ]; + + # programs.bash = { + # enable = true; + # initExtra = '' + # if uwsm check may-start && uwsm select; then + # exec systemd-cat -t uwsm_start uwsm start default + # fi + # ''; + # }; programs.git = { enable = true;