It's replaced by this new guide which supports both 64-bit and 32-bit libraries.
This guide will show you how to download, compile and install the nvidia-legacy-340xx-driver on Debian 12. Some people install the driver directly from sid but this will mix packages from both stable and unstable which may create issues. It's recommended to update and upgrade your system before you start.
It was reported to work with nvidia-legacy-390xx-driver just replace the appropriate package names.
Install these packages.
sudo apt install build-essential fakeroot devscriptsYou can manually download the source code from debian.org and go to Step 2 or continue with Step 1. Don't worry you won't be able to install packages from sid.
Add 'deb-src http://httpredir.debian.org/debian unstable main non-free contrib' to '/etc/apt/sources.list'.
Update your system.
sudo apt updateCreate these folders.
mkdir -p Build/nvidia340 Build/nvidia-settingsDownload the driver in 'Build/nvidia340'.
apt source nvidia-legacy-340xx-driverDownload the nvidia-settings in 'Build/nvidia-settings'.
apt source nvidia-settings-legacy-340xxDelete 'deb-src http://httpredir.debian.org/debian unstable main non-free contrib' from '/etc/apt/sources.list'.
Update your system.
sudo apt updateRun
debuild -b -uc -usin both folders 'Build/nvidia340/nvidia-graphics-drivers-legacy-340xx-340.108' and 'Build/nvidia-settings/nvidia-settings-legacy-340xx-340.108'.
It will complain about missing build dependencies. Install them.
# Example
# sudo apt install debhelper-compat m4 libgl-dev libgtk2.0-dev libjansson-dev libvdpau-dev libxext-dev libxv-dev libxxf86vm-dev pkg-config xserver-xorg-dev debhelper dh-dkms patchelf po-debconf quilt linux-headers-amd64Run again
debuild -b -uc -usin both folders 'Build/nvidia340/nvidia-graphics-drivers-legacy-340xx-340.108' and 'Build/nvidia-settings/nvidia-settings-legacy-340xx-340.108' to compile the driver.
Make a new folder '/nvidia'.
sudo mkdir /nvidiaCopy all *.deb files from 'Build/nvidia340' and 'Build/nvidia-settings' inside '/nvidia'.
sudo cp *.deb /nvidiaCreate 'Packages'.
cd /nvidia
sudo sh -c 'dpkg-scanpackages . > Packages'Add 'deb [trusted=yes] file:/nvidia ./' to '/etc/apt/sources.list'.
Enable 'contrib' in your '/etc/apt/sources.list'.
# Example
# deb http://deb.debian.org/debian bookworm main non-free-firmware contribFor each additional kernel you have to manually install the respective linux-headers.
Update your system and install the driver.
sudo apt update
sudo apt install nvidia-legacy-340xx-driver nvidia-settings-legacy-340xx
# If the above line doesn't work try with
# sudo apt install --no-install-recommends --no-install-suggests nvidia-legacy-340xx-driver nvidia-settings-legacy-340xx libgles1-nvidia-legacy-340xx libgles2-nvidia-legacy-340xxIt's recommended to uninstall all other video drivers or at least nouveau.
sudo apt autoremove xserver-xorg-video-nouveauCreate a file /etc/X11/xorg.conf (to configure NVIDIA Optimus - read the comments).
Section "Device"
Identifier "Device0"
Driver "nvidia"
VendorName "NVIDIA Corporation"
EndSection
Section "ServerFlags"
Option "IgnoreABI" "1"
EndSection
I would definitely keep the source code because I might have to rebuild the driver in the future otherwise you can run.
rm -r Build/nvidia340 Build/nvidia-settings
rmdir BuildYou can remove 'deb [trusted=yes] file:/nvidia ./' from '/etc/apt/sources.list' and update your system.
You can also delete '/nvidia' and all *.deb files.
sudo rm -r /nvidiahttps://wiki.debian.org/SourcesList
https://wiki.debian.org/BuildingTutorial
https://wiki.debian.org/DebianRepository/Setup



@grosioso I don't know and why you want that? Everything you need to set is done in the xorg config file. You have to expect compatibility issues.
@estapeluo @MaximSAzh First you shouldn't compile as root. Only the commands starting with
sudoshould. Second the information you provide is not enough for me to understand what's wrong. The most probable reasons I can think of are:You don't have the kernel headers - install the kernel header from the backports.
The backports kernel is not supported - install the older one.
Your source is too old - re download.
You don't have dkms installed.