Simple instructions on how to install nVidia drivers for X11 on Debian written by Len Sorensen. (LSorensen on irc.debian.org, lsorense -at- csclub.uwaterloo.ca, http://www.tinyplanet.ca/~lsorense/)

Last updated Jan 05, 2010.
Feel free to email reports on this information working or not working and any suggestions you have on making it better.
I am now an assistant maintainer of the nvidia driver packages in Debian.

At this time these are the Debian versions:
LennyDebian 5.0 stable release
SqueezeDebian testing release (will be next stable release when done)
SidDebian unstable (will never be released, but provides packages for testing after they have been tested for a while.)

Step 0: Cleaning up the mess from nvidia's installer (if you used it first):
Make sure to remove all the garbage created by the nvidia installer, since it places files in different locations, and may cause problems even after following these instructions. It is supposed to have an uninstall option. Something like: nvidia-installer --uninstall should do it. I have not used it myself, since doing it this way is so simple and works very well, and of course: It is `The Debian Way'. The --uninstall option should remove everything it installed (At least I hope so.)
Do NOT try to mix and match with the debian packages and the nvidia installer. They do not get along, they don't agree on where files should go or how just about anything should be done. It's one way or the other. To do it right the Debian way, all traces of the nvidia installer has to go. In fact the nvidia installer doesn't agree with where Debian installs files.

Step 1: Preparing your package sources
Ensure you have main contrib non-free in your /etc/apt/sources.list since the nvidia drivers are in non-free and some of the helpers are in contrib.

Step 2: Ensure your kernel is the right version.

Please make sure you are running an up to date kernel so that the headers matching it can be installed.
For i386 any intel chip would be 686 unless it is a really old pentium or 486 in which case you use 486. An AMD system would be 686 for Athlon and for K6 and older use 486.
CPU TypeCommand
i386: 486, Pentium, K5, K6, etc.apt-get install linux-image-2.6-486
i386: Athlon, Pentium Pro, P2, P3, P4, etc.apt-get install linux-image-2.6-686
amd64: Any AMD or Intelapt-get install linux-image-2.6-amd64
That will keep you running the latest kernel released by Debian. If the command to install linux-headers fails later, you didn't do this step right.
Remember to reboot after installing a new kernel so that you are running the right one. If you already had the current kernel, you can just continue.

Step 3: Installing needed packages for building the nvidia kernel module.
Install a few packages needed:
apt-get install nvidia-kernel-common module-assistant

If you are running a debian kernel do this:
m-a -i -t prepare
If you built your own kernel, just make sure you know where the source for it is located so you can pass the location to m-a.

NOTE: If you are using an older nvidia chip you may have to use a legacy driver instead of the current one.

On Etch the current driver supports at least all geforce 7xxx series cards as far as I know, although not any 8xxx series cards that I know of. Unstable supports 8xxx cards using the 1xx series drivers (currently 169 as of this writing)

Geforce 4 and older require a 96xx legacy driver on unstable, and Geforce 2 (but not 2 MX or other integrated video chips) require the 71xx legacy driver.

Replace nvidia-glx, nvidia-glx-dev and nvidia-kernel-source like this in all the following instructions:
Chip Generationnvidia-glxnvidia-glx-devnvidia-kernel-source
Geforce 2 and older (like TNT)nvidia-glx-legacy-71xxnvidia-glx-legacy-71xx-devnvidia-kernel-legacy-71xx
Geforce 4 and older (including 2 MX)nvidia-glx-legacy-96xxnvidia-glx-legacy-96xx-devnvidia-kernel-legacy-96xx
Geforce FX 5xxx up to 7xxx without SSE capable CPUnvidia-glx-legacy-96xxnvidia-glx-legacy-96xx-devnvidia-kernel-legacy-96xx
Geforce FX 5xxx up to 8xxx with SSE cabable CPU on Lenny and Squeeze (until 18x.xx drivers move to Squeze then treat it as Sid)nvidia-glxnvidia-glx-devnvidia-kernel
Geforce FX 5xxx on Sidnvidia-glx-legacy-173xxnvidia-glx-legacy-173xx-devnvidia-kernel
Geforce FX 6xxx and newer on Sidnvidia-glxnvidia-glx-devnvidia-kernel
The newer drivers don't support systems without SSE, but since only AGP and PCI systems don't have SSE, the 96xx driver should be sufficient since it covers all AGP cards. Only 8xxx (and newer) series cards would be a problem, but those are only PCI express, which is only found on systems which have SSE.

If you don't get this right, you will get a message when you try to start X telling you that your chip requires using legacy driver 96.xx.xx or 71.xx.xx in which case go back and try again using that version. You should probably 'apt-get remove nvidia-glx nvidia-glx-dev nvidia-kernel-source' first before installing the legacy driver.

nvidia still supports these legacy drivers, but they are only updated whenever a new kernel version or X server release requires small changes to the driver interface. New features are only added to the current drivers which makes sense since there probably aren't any new features that would even work on the old chips anyhow.

Step 4: Building and installing the nvidia kernel module
Build the kernel module package:
m-a clean,a-i -i -t -f nvidia-kernel-source
depmod -a
or if using your own kernel build:
m-a clean,a-i -i -t -f -k /usr/src/kernelsourcepath nvidia-kernel-source
depmod -a
Where /usr/src/kernelsourcepath is the location of your kernelsource

Step 5: Installing and configuring the nvidia glx X driver
Install the last few packages:
apt-get install nvidia-glx nvidia-glx-dev nvidia-xconfig xserver-xorg
Make sure that the version number of your nvidia-glx matches exactly the version number of the nvidia-kernel-source package you installed, otherwise it won't work. So if you grab the package for one from unstable for use on testing, you will have to grab the other one too.

Now you are ready to change X to use the new driver. Configure X normally using:
dpkg-reconfigure xserver-xorg
Configure the mouse and keyboard layout as you need. If you ever edited the xorg.conf file manually, the simplest way to overwrite it with one that has the new values is to run dexconf. If you never edited it yourself, it should just auto update with the new settings.
To enable the use of the nvidia driver, run nvidia-xconfig. This will setup the xorg.conf to use the nvidia driver rather than the default nv driver. It is possible to pass various options to nvidia-xconfig to setup tv output, multiple monitors and various other options, but that is currently beyond the scope of this howto.

Some older cards may need to be told to allow composite and glx at the same time or you don't get any opengl support. To do this run nvidia-xconfig --allow-glx-with-composite.

If you want to run dual monitors run nvidia-xconfig --twinview.

Note: Any user that wants to run 3D code must be in the video group.
To add a user to the video group do this:
adduser youruser video
The next time they login to X they will have 3D access.

That's it. You should be running the new X. You should see the nvidia logo when X starts if you are succesfully running the new driver.

Notes:
Keep in mind that whenever a new version of the nvidia driver comes out, or whenever you upgrade to a newer kernel, you will have to repeat step 4 again to build the nvidia kernel module to match the new driver and/or new kernel.

If the nvidia modules doesn't load automatically and the X server complains about it, add 'nvidia' to /etc/modules to make it auto load on boot.

When upgrading, the simplest is to reboot afterwards to make sure X and the kernel module are using the same version. You could also stop X; modprobe -r nvidia; modprobe nvidia; start X again.

If you are running amd64 you might want to also install the nvidia-glx-ia32 package in case you run any 32bit programs on your system, or if you use a 32bit chroot there should be a way to install the nvidia-glx package in the chroot, although it may complain about not having any of the kernel driver packages installed. I guess installing nvidia-kernel-modules-686 or something like that in the chroot would shut it up, or you could use equivs to generate a fake package to fulfill the dependancy. If anyone ever asks for details on this I can expand further. I should have my own amd64 machine pretty soon so I can actually try that out.