Skip to content

Instantly share code, notes, and snippets.

@m1st0
Last active July 2, 2025 08:44
Show Gist options
  • Save m1st0/3957db900736b5a01d16b8ef1b0ddd69 to your computer and use it in GitHub Desktop.
Save m1st0/3957db900736b5a01d16b8ef1b0ddd69 to your computer and use it in GitHub Desktop.
Install the proper Nvidia drivers against service conflicts for Wayland
Package: nvidia-kernel-common-570
Version: 0.0.1
Provides: nvidia-kernel-common-570
Conflicts: nvidia-kernel-common-570
#!/usr/bin/zsh
# Install the proper Nvidia drivers against service conflicts for Wayland
# Author: Maulik Mistry
# Please share support: https://www.paypal.com/paypalme/m1st0
# License: BSD License 2.0
# Copyright (c) 2023–2025, Maulik Mistry
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the <organization> nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
## Prevent conflicting services from being installed.
# Define where the source file is (your custom preference file)
SOURCE_FILE="nvidia-kernel-common-570"
# Define the target path
TARGET_PATH="/etc/apt/preferences.d/nvidia-kernel-common-570"
# Check if source file exists
if [[ ! -f "$SOURCE_FILE" ]]; then
echo "Source file $SOURCE_FILE does not exist. Please create it first."
exit 1
fi
# Need root permissions to symlink into /etc
echo "Creating symlink as root..."
sudo cp "$SOURCE_FILE" "$TARGET_PATH"
if [[ $? -eq 0 ]]; then
echo "Nvidia conflicting package services prevented from install: "
ll $TARGET_PATH
else
echo "Failed to create symlink."
fi
kernel_name=$(uname -r)
# Define the packages to check
packages=(
"linux-modules-nvidia-570-${kernel_name}"
"linux-objects-nvidia-570-${kernel_name}"
"linux-signatures-nvidia-${kernel_name}"
"nvidia-utils-570"
"libnvidia-gl-570"
# Until we have X11 gone.
"xserver-xorg-video-nvidia-570"
)
# Function to check if a package is installed
is_installed() {
dpkg -l | grep -q "^ii $1"
}
# Check if each package is installed
all_installed=true
for package in "${packages[@]}"; do
if ! is_installed "$package"; then
echo "$package is not installed."
all_installed=false
else
echo "$package is already installed."
fi
done
# Install packages if any are missing
if [ "$all_installed" = false ]; then
echo "Installing missing packages..."
sudo apt install "${packages[@]}"
else
echo "All packages are already installed."
fi
# To prevent Nvidia modules from taking precedence on load during Ubuntu 25.04
# which results in SDDM failing, add a blacklist file for the modules so they
# only load on demand.
sudo tee /etc/modprobe.d/blacklist-nvidia.conf > /dev/null <<EOF
blacklist nvidia
blacklist nvidia-drm
blacklist nvidia-modeset
blacklist nvidia-uvm
EOF
# Turn off nvidia services that are causing conflicts.
sudo ln -sf /dev/null ./system/systemd-hibernate.service.requires/nvidia-hibernate.service
sudo systemctl mask nvidia-hibernate.service nvidia-suspend.service sys-bus-pci-drivers-nvidia.device nvidia-resume.service nvidia-fabricmanager.service nvidia-persistenced.service nvidia-suspend-then-hibernate.service
echo "✅ NVIDIA modules blacklisted for manual loading"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment