diff options
| author | Ahmed Abdelhalim <[email protected]> | 2026-01-24 15:46:51 +0100 |
|---|---|---|
| committer | Ahmed Abdelhalim <[email protected]> | 2026-01-24 15:46:51 +0100 |
| commit | 9c9c80f240e45102e8c037feb617c282d4b36479 (patch) | |
| tree | 2a1977cb7bc5aa29101edf8a1746b33a7268d275 | |
| parent | d7b3463a79a50dc81d28d530c5212a1749efbb15 (diff) | |
Add nvidia driver role w/testing
Fix nvidia role for clean installs and make hyprland nvidia env vars conditional
- Add nouveau blacklist to prevent driver conflicts
- Remove redundant DKMS install task (AUR package handles this automatically)
- Fix mkinitcpio MODULES to append nvidia modules instead of overwriting
- Add missing initramfs rebuild notification to modprobe.d template
- Make hyprland NVIDIA environment variables conditional via hyprland_nvidia flag
Co-authored-by: Claude.ai
| -rw-r--r-- | configure.yml | 1 | ||||
| -rw-r--r-- | molecule/archlinux-gnome/converge.yml | 1 | ||||
| -rw-r--r-- | molecule/archlinux/converge.yml | 1 | ||||
| -rw-r--r-- | roles/hyprland/defaults/main.yml | 2 | ||||
| -rw-r--r-- | roles/hyprland/meta/argument_specs.yml | 6 | ||||
| -rw-r--r-- | roles/hyprland/templates/hyprland/envs.conf.j2 | 7 | ||||
| -rw-r--r-- | roles/nvidia/defaults/main.yml | 15 | ||||
| -rw-r--r-- | roles/nvidia/handlers/main.yml | 6 | ||||
| -rw-r--r-- | roles/nvidia/meta/main.yml | 12 | ||||
| -rw-r--r-- | roles/nvidia/tasks/install-archlinux.yml | 40 | ||||
| -rw-r--r-- | roles/nvidia/tasks/main.yml | 3 | ||||
| -rw-r--r-- | roles/nvidia/templates/nvidia.conf.j2 | 4 |
12 files changed, 97 insertions, 1 deletions
diff --git a/configure.yml b/configure.yml index ee1536b0..ceb92852 100644 --- a/configure.yml +++ b/configure.yml @@ -33,6 +33,7 @@ - role: "neomutt" - role: "firefox" - role: "alacritty" + - role: "nvidia" - role: "hyprland" - name: "Ubuntu configure" diff --git a/molecule/archlinux-gnome/converge.yml b/molecule/archlinux-gnome/converge.yml index 3324704e..90090248 100644 --- a/molecule/archlinux-gnome/converge.yml +++ b/molecule/archlinux-gnome/converge.yml @@ -84,3 +84,4 @@ - role: "pipewire" - role: "brightnessctl" - role: "wiremix" + - role: "nvidia" diff --git a/molecule/archlinux/converge.yml b/molecule/archlinux/converge.yml index 015bc262..38983ecb 100644 --- a/molecule/archlinux/converge.yml +++ b/molecule/archlinux/converge.yml @@ -83,4 +83,5 @@ - role: "pipewire" - role: "brightnessctl" - role: "wiremix" + - role: "nvidia" - role: "hyprland" diff --git a/roles/hyprland/defaults/main.yml b/roles/hyprland/defaults/main.yml new file mode 100644 index 00000000..b385f701 --- /dev/null +++ b/roles/hyprland/defaults/main.yml @@ -0,0 +1,2 @@ +--- +hyprland_nvidia: false diff --git a/roles/hyprland/meta/argument_specs.yml b/roles/hyprland/meta/argument_specs.yml index b12c2ac5..202ee019 100644 --- a/roles/hyprland/meta/argument_specs.yml +++ b/roles/hyprland/meta/argument_specs.yml @@ -3,4 +3,8 @@ argument_specs: main: short_description: "Install hyprland on ArchLinux" description: "Install hyprland on ArchLinux" - options: {} + options: + hyprland_nvidia: + type: "bool" + default: false + description: "Enable NVIDIA-specific environment variables for Wayland" diff --git a/roles/hyprland/templates/hyprland/envs.conf.j2 b/roles/hyprland/templates/hyprland/envs.conf.j2 index c2bd38de..afd84a20 100644 --- a/roles/hyprland/templates/hyprland/envs.conf.j2 +++ b/roles/hyprland/templates/hyprland/envs.conf.j2 @@ -19,3 +19,10 @@ env = XDG_SESSION_TYPE,wayland # Allow better support for screen sharing (Google Meet, Discord, etc) env = XDG_CURRENT_DESKTOP,Hyprland env = XDG_SESSION_DESKTOP,Hyprland + +{% if hyprland_nvidia %} +# NVIDIA Wayland support +env = LIBVA_DRIVER_NAME,nvidia +env = __GLX_VENDOR_LIBRARY_NAME,nvidia +env = NVD_BACKEND,direct +{% endif %} diff --git a/roles/nvidia/defaults/main.yml b/roles/nvidia/defaults/main.yml new file mode 100644 index 00000000..8fc2a510 --- /dev/null +++ b/roles/nvidia/defaults/main.yml @@ -0,0 +1,15 @@ +--- +nvidia_aur_packages: + - "nvidia-580xx-dkms" + - "nvidia-580xx-utils" + +nvidia_packages: + - "linux-headers" + - "nvidia-settings" + - "libva-nvidia-driver" + +nvidia_modules: + - "nvidia" + - "nvidia_modeset" + - "nvidia_uvm" + - "nvidia_drm" diff --git a/roles/nvidia/handlers/main.yml b/roles/nvidia/handlers/main.yml new file mode 100644 index 00000000..67408c79 --- /dev/null +++ b/roles/nvidia/handlers/main.yml @@ -0,0 +1,6 @@ +--- +- name: "Rebuild initramfs" + become: true + ansible.builtin.command: + cmd: "mkinitcpio -P" + changed_when: true diff --git a/roles/nvidia/meta/main.yml b/roles/nvidia/meta/main.yml new file mode 100644 index 00000000..cc0ec526 --- /dev/null +++ b/roles/nvidia/meta/main.yml @@ -0,0 +1,12 @@ +--- +dependencies: + - role: "yay" +galaxy_info: + author: "a14m" + description: "Install and configure NVIDIA proprietary drivers" + license: "MIT" + min_ansible_version: "2.18" + platforms: + - name: "ArchLinux" + versions: + - "all" diff --git a/roles/nvidia/tasks/install-archlinux.yml b/roles/nvidia/tasks/install-archlinux.yml new file mode 100644 index 00000000..cbcc2221 --- /dev/null +++ b/roles/nvidia/tasks/install-archlinux.yml @@ -0,0 +1,40 @@ +--- +- name: "Install NVIDIA packages" + become: true + ansible.builtin.package: + name: "{{ nvidia_packages }}" + state: "present" + +- name: "Install NVIDIA driver from AUR" + become: true + become_user: "aur_builder" + kewlfft.aur.aur: + name: "{{ nvidia_aur_packages }}" + state: "present" + use: "yay" + +- name: "Configure NVIDIA DRM kernel mode setting" + become: true + ansible.builtin.template: + src: "nvidia.conf.j2" + dest: "/etc/modprobe.d/nvidia.conf" + mode: "0644" + notify: "Rebuild initramfs" + +- name: "Get current mkinitcpio MODULES" + become: true + ansible.builtin.shell: + cmd: "grep '^MODULES=' /etc/mkinitcpio.conf | sed 's/MODULES=(\\(.*\\))/\\1/'" + register: "current_modules" + changed_when: false + +- name: "Add NVIDIA modules to mkinitcpio" + become: true + vars: + existing_modules: "{{ current_modules.stdout.split() | reject('in', nvidia_modules) | list }}" + all_modules: "{{ existing_modules + nvidia_modules }}" + ansible.builtin.lineinfile: + path: "/etc/mkinitcpio.conf" + regexp: "^MODULES=\\(.*\\)" + line: "MODULES=({{ all_modules | join(' ') }})" + notify: "Rebuild initramfs" diff --git a/roles/nvidia/tasks/main.yml b/roles/nvidia/tasks/main.yml new file mode 100644 index 00000000..71bcbd0d --- /dev/null +++ b/roles/nvidia/tasks/main.yml @@ -0,0 +1,3 @@ +--- +- name: "Include OS-specific tasks" + ansible.builtin.include_tasks: "install-{{ ansible_facts['os_family'] | lower }}.yml" diff --git a/roles/nvidia/templates/nvidia.conf.j2 b/roles/nvidia/templates/nvidia.conf.j2 new file mode 100644 index 00000000..9672977e --- /dev/null +++ b/roles/nvidia/templates/nvidia.conf.j2 @@ -0,0 +1,4 @@ +blacklist nouveau + +options nvidia_drm modeset=1 +options nvidia_drm fbdev=1 |
