Building your own Nvidia packages



So you want to try out a newer version of the Nvidia driver, but want to install a package instead of running the Nvidia bundle?

Don’t want to wait for the Manjaro devs to update the driver, or want to try out a beta driver instead?

Don’t mind the extra maintenance of building your own driver modules?

Are you going to remember to do this each and every time you install a new kernel version?

Update: PKGBUILDs for “most recent” driver are available here:

Outline instructions:

git clone
cd manjaro-nvidia/nvidia-utils
makepkg -Csrc
sudo pacman -Udd *pkg*xz
cd ../nvidia-414
makepkg -Csric

In-depth instructions for creating/editing your own PKGBUILDs

Warning: These steps are entirely unsupported and followed at your own risk. By following this guide you’re admitting you’re someone who is comfortable with fixing your own system.

OK? Then read on…

Nvidia drivers and tooling are split over a number of packages. The key PKGBUILDs are in -extra, e.g.:

and if you run Steam or 32-bit applications you’ll want:

Editing these PKGBUILD files will allow you build your own kernel modules that follow the Manjaro tooling, meaning you shouldn’t end up breaking your system.

Step 1

Prepare a Live CD/USB so you can fix your system or switch the drivers back to the repo versions.

Step 2

Download all the files from the nvidia-utils, (lib32-nvidia-utils,) and linux*-extramodules/nvidia directories on GitHub. Obviously, pick the extramodules that match your running kernel. If you have more then one kernel installed you’ll need to build multiple modules.

You’ll want to put these in separate directories, e.g. nvidia-utils, linux412-nvidia, etc.

Step 3

Edit the PKGBUILD files and change the pkgver variable to match the upstream driver version. Change the pkgrel to 0 so any official package update will be installed in preference.

TIP: add a suffix that matches your kernel version so you know whether you built for the current version, e.g. for 4.12.8, use pkgrel=0.8.

Step 4

Download the necessary files and update the checksums for the PKGBUILD files. In each directory, run:


Step 5 part 1

Try building the nvidia-util PKGBUILD (makepkg -srcC). If you get errors, resolve them; for example, files might have moved or been renamed.

Check in the src subdirectory for the source files if e.g. files cannot be found. You may need to delete the pkg and src directories manually before each build attempt.

Here’s an edited PKGBUILD for 384.59:

# Contributor: Thomas Baechler <>
# Maintainer: Philip Müller <philm[at]manjaro[dog]org>

pkgname=('nvidia-utils' 'opencl-nvidia' 'mhwd-nvidia')
arch=('i686' 'x86_64')
source=('mhwd-nvidia' 'nvidia-drm-outputclass.conf')

[[ "$CARCH" = "i686" ]] && _pkg="NVIDIA-Linux-x86-${pkgver}"
#[[ "$CARCH" = "x86_64" ]] && _pkg="NVIDIA-Linux-x86_64-${pkgver}"
[[ "$CARCH" = "x86_64" ]] && _pkg="NVIDIA-Linux-x86_64-${pkgver}-no-compat32"

create_links() {
    # create soname links
    for _lib in $(find "${pkgdir}" -name '*.so*' | grep -v 'xorg/'); do
        _soname=$(dirname "${_lib}")/$(readelf -d "${_lib}" | grep -Po 'SONAME.*: \[\K[^]]*' || true)
        _base=$(echo ${_soname} | sed -r 's/(.*).so.*/\')
        [[ -e "${_soname}" ]] || ln -s $(basename "${_lib}") "${_soname}"
        [[ -e "${_base}" ]] || ln -s $(basename "${_soname}") "${_base}"

prepare() {
    sh "${_pkg}.run" --extract-only

    cd "${_pkg}"
    bsdtar -xf nvidia-persistenced-init.tar.bz2

package_opencl-nvidia() {
    pkgdesc="OpenCL implemention for NVIDIA"
    optdepends=('opencl-headers: headers necessary for OpenCL development')
    provides=('opencl-nvidia' 'opencl-driver')
    cd "${_pkg}"

    # OpenCL
    install -D -m644 nvidia.icd "${pkgdir}/etc/OpenCL/vendors/nvidia.icd"
    install -D -m755 "${pkgver}" "${pkgdir}/usr/lib/${pkgver}"
    install -D -m755 "${pkgver}" "${pkgdir}/usr/lib/${pkgver}"


    mkdir -p "${pkgdir}/usr/share/licenses"
    ln -s nvidia "${pkgdir}/usr/share/licenses/opencl-nvidia"

package_mhwd-nvidia() {
    pkgdesc="MHWD module-ids for nvidia $pkgver"

    install -d -m755 "${pkgdir}/var/lib/mhwd/ids/pci/"

    # Generate mhwd database
    sh -e ${srcdir}/mhwd-nvidia \
    ${srcdir}/${_pkg}/README.txt \
    ${srcdir}/${_pkg}/kernel/nvidia/nv-kernel.o_binary \
    > ${pkgdir}/var/lib/mhwd/ids/pci/nvidia.ids

package_nvidia-utils() {
    pkgdesc="NVIDIA drivers utilities"
    depends=('xorg-server' 'libglvnd' 'mhwd')
    optdepends=('gtk2: nvidia-settings'
                'xorg-server-devel: nvidia-xconfig'
                'opencl-nvidia: OpenCL support')

    cd "${_pkg}"

    # X driver
    install -D -m755 "${pkgdir}/usr/lib/xorg/modules/drivers/"

    # GLX extension module for X
    install -D -m755 "${pkgver}" "${pkgdir}/usr/lib/nvidia/xorg/${pkgver}"
    ln -s "${pkgver}" "${pkgdir}/usr/lib/nvidia/xorg/"	# X doesn't find glx otherwise
    ln -s "${pkgver}" "${pkgdir}/usr/lib/nvidia/xorg/"	# X doesn't find glx otherwise
    install -D -m755 "${pkgver}" "${pkgdir}/usr/lib/${pkgver}"
    #ln -s "${pkgver}" "${pkgdir}/usr/lib/"

    # Wayland
    install -D -m755 "" "${pkgdir}/usr/lib/${pkgver}"
    ln -s "${pkgver}" "${pkgdir}/usr/lib/"

    # OpenGL library
    install -D -m755 "" "${pkgdir}/usr/lib/nvidia/"
    install -D -m755 "" "${pkgdir}/usr/lib/nvidia/"
    install -D -m755 "${pkgver}" "${pkgdir}/usr/lib/${pkgver}"
    install -D -m755 "${pkgver}" "${pkgdir}/usr/lib/${pkgver}"
    install -D -m755 "${pkgver}" "${pkgdir}/usr/lib/${pkgver}"
    install -D -m644 "10_nvidia.json" "${pkgdir}/usr/share/glvnd/egl_vendor.d/10_nvidia.json"

    # OpenGL core library
    install -D -m755 "${pkgver}" "${pkgdir}/usr/lib/${pkgver}"
    install -D -m755 "${pkgver}" "${pkgdir}/usr/lib/${pkgver}"
    install -D -m755 "${pkgver}" "${pkgdir}/usr/lib/${pkgver}"

    # misc
    install -D -m755 "${pkgver}" "${pkgdir}/usr/lib/${pkgver}"
    install -D -m755 "${pkgver}" "${pkgdir}/usr/lib/${pkgver}"
    install -D -m755 "${pkgver}" "${pkgdir}/usr/lib/${pkgver}"
    install -D -m755 "${pkgver}" "${pkgdir}/usr/lib/${pkgver}"
    install -D -m755 "${pkgver}" "${pkgdir}/usr/lib/${pkgver}"

    # Vulkan ICD
    install -D -m644 "nvidia_icd.json.template" "${pkgdir}/usr/share/vulkan/icd.d/nvidia_icd.json"

    # VDPAU
    install -D -m755 "${pkgver}" "${pkgdir}/usr/lib/vdpau/${pkgver}"

    # nvidia-tls library
    install -D -m755 "${pkgver}" "${pkgdir}/usr/lib/${pkgver}"
    install -D -m755 "tls/${pkgver}" "${pkgdir}/usr/lib/tls/${pkgver}"

    # CUDA
    install -D -m755 "${pkgver}" "${pkgdir}/usr/lib/${pkgver}"
    install -D -m755 "${pkgver}" "${pkgdir}/usr/lib/${pkgver}"

    # PTX JIT Compiler (Parallel Thread Execution (PTX) is a pseudo-assembly language for CUDA)
    install -D -m755 "${pkgver}" "${pkgdir}/usr/lib/${pkgver}"

    # Fat (multiarchitecture) binary loader
    install -D -m755 "${pkgver}" "${pkgdir}/usr/lib/${pkgver}"

    # DEBUG
    install -D -m755 nvidia-debugdump "${pkgdir}/usr/bin/nvidia-debugdump"

    # nvidia-xconfig
    install -D -m755 nvidia-xconfig "${pkgdir}/usr/bin/nvidia-xconfig"
    install -D -m644 nvidia-xconfig.1.gz "${pkgdir}/usr/share/man/man1/nvidia-xconfig.1.gz"

    # nvidia-settings
    install -D -m755 nvidia-settings "${pkgdir}/usr/bin/nvidia-settings"
    install -D -m644 nvidia-settings.1.gz "${pkgdir}/usr/share/man/man1/nvidia-settings.1.gz"
    install -D -m644 nvidia-settings.desktop "${pkgdir}/usr/share/applications/nvidia-settings.desktop"
    install -D -m644 nvidia-settings.png "${pkgdir}/usr/share/pixmaps/nvidia-settings.png"
    install -D -m755 "$pkgver" "$pkgdir/usr/lib/$pkgver"
    install -D -m755 "$pkgver" "$pkgdir/usr/lib/$pkgver"
    sed -e 's:__UTILS_PATH__:/usr/bin:' -e 's:__PIXMAP_PATH__:/usr/share/pixmaps:' -i "${pkgdir}/usr/share/applications/nvidia-settings.desktop"

    # nvidia-bug-report
    install -D -m755 "${pkgdir}/usr/bin/"

    # nvidia-smi
    install -D -m755 nvidia-smi "${pkgdir}/usr/bin/nvidia-smi"
    install -D -m644 nvidia-smi.1.gz "${pkgdir}/usr/share/man/man1/nvidia-smi.1.gz"

    # nvidia-cuda-mps
    install -D -m755 nvidia-cuda-mps-server "${pkgdir}/usr/bin/nvidia-cuda-mps-server"
    install -D -m755 nvidia-cuda-mps-control "${pkgdir}/usr/bin/nvidia-cuda-mps-control"
    install -D -m644 nvidia-cuda-mps-control.1.gz "${pkgdir}/usr/share/man/man1/nvidia-cuda-mps-control.1.gz"

    # nvidia-modprobe
    # This should be removed if nvidia fixed their uvm module!
    install -D -m4755 nvidia-modprobe "${pkgdir}/usr/bin/nvidia-modprobe"
    install -D -m644 nvidia-modprobe.1.gz "${pkgdir}/usr/share/man/man1/nvidia-modprobe.1.gz"

    # nvidia-persistenced
    install -D -m755 nvidia-persistenced "${pkgdir}/usr/bin/nvidia-persistenced"
    install -D -m644 nvidia-persistenced.1.gz "${pkgdir}/usr/share/man/man1/nvidia-persistenced.1.gz"
    install -D -m644 nvidia-persistenced-init/systemd/nvidia-persistenced.service.template "${pkgdir}/usr/lib/systemd/system/nvidia-persistenced.service"
    sed -i 's/__USER__/nvidia-persistenced/' "${pkgdir}/usr/lib/systemd/system/nvidia-persistenced.service"

    # application profiles
    install -D -m644 nvidia-application-profiles-${pkgver}-rc "${pkgdir}/usr/share/nvidia/nvidia-application-profiles-${pkgver}-rc"
    install -D -m644 nvidia-application-profiles-${pkgver}-key-documentation "${pkgdir}/usr/share/nvidia/nvidia-application-profiles-${pkgver}-key-documentation"

    install -D -m644 LICENSE "${pkgdir}/usr/share/licenses/nvidia/LICENSE"
    ln -s nvidia "${pkgdir}/usr/share/licenses/nvidia-utils"
    install -D -m644 README.txt "${pkgdir}/usr/share/doc/nvidia/README"
    install -D -m644 NVIDIA_Changelog "${pkgdir}/usr/share/doc/nvidia/NVIDIA_Changelog"
    cp -r html "${pkgdir}/usr/share/doc/nvidia/"
    ln -s nvidia "${pkgdir}/usr/share/doc/nvidia-utils"

    # distro specific files must be installed in /usr/share/X11/xorg.conf.d
    install -m755 -d "${pkgdir}/usr/share/X11/xorg.conf.d"
    install -m644 "${srcdir}/nvidia-drm-outputclass.conf" "${pkgdir}/usr/share/X11/xorg.conf.d/"


Step 5 part 2

Install the new packages, e.g.

sudo pacman -Udd nvidia-utils-1:384.59-0-x86_64.pkg.tar.xz mhwd-nvidia-1:384.59-0-any.pkg.tar.xz

-dd is necessary as this will break older installed extramodules. DO NOT REBOOT HERE.

Step 5 part 3

Repeat part 1 above for lib32-nvidia-utils should you need it:

  • Edit the PKGBUILD file in the same way; any changes to file locations will be the same as for nvidia-utils
  • Build and install with makepkg -Csric

The packages do not have a version requirement so can be built and installed in one go.

Step 6

Build and install the extramodule (makepkg -sric). This shouldn’t need any intervention.

Step 7

Build the module for any other kernels you have installed.

Step 8

Cross your fingers and reboot.

Step 9+

Rebuild the extramodules every time you install or update your kernel(s). This ensures they will work correctly with any changes in the kernel.

Step Z

Want to switch back to the repo versions? Easy:

sudo pacman -Syuu

will downgrade your packages back to those in the repos.

Further reading:

Tutorial - How to Install Nvidia drivers from the Nvidia website
How about now ? Will manjaro update its old and buggy nvidia driver?
Nvidia drivers update
[Unstable Update] 2017-07-29 - Kernels, Virtualbox, spl/zfs, Cinnamon, Pamac
Request: can we have a faster push for nvidia-390 to the stable branch?
Cuda version issue.. I updated, it broke all cuda functionality because everything wants 9.0, not 9.1
How to downgrade NVIDIA drivers?
Why install packages instead of running installer script?
Why install packages instead of running installer script?
Is it safe to postpone nvidia driver updates?
[Testing Update] 2018-01-18 - Kernels, Systemd, Pamac, KDE FW, Haskell, Python
Bumblebee - upgrading Nvidia drivers from stable version 384 to beta version 390
Screen Tearing on Gnome running Bumblebee
Installation problem of nvidia driver
Installation problem of nvidia driver
Cuda 9.1. not compatible with nvidia 384
OpenGL 4.6 NVIDIA?

Let me just add that it’s highly recommended to rebuild the nvidia module with each kernel upgrade.

For the rest: perfect tutorial! I followed a very similar procedure last year and it worked well.


Would be nice to here from $tester, which card and kernel works…!

Why can I edit your post?
Is this intentionally?


That’s the fourth line of the post. :wink:

It’s a wiki post. It means others can update it if needed and I’m not around/busy/hiding.


Oh dear, I read through this too quickly :slight_smile:


Let me go and add a

Step 9

Rebuild the extramodules every time you install or update your kernel(s).


You might wan’t to change the makepkg command in Step 4 part 1, since the -i option is not working and it is not always a good idea to install every packages makepkg build. But on Step 5 the -i option is maybe handy.

Also I would also suggest the -c option of makepkg. It cleans the build folder after a successful build.


Removing -i makes sense - you’re right, it won’t work when dependencies need to be ignored.

I also like -c now - I thought it cleaned after any build which isn’t useful for resolving build issues, but it only cleans after successful builds, which is fine.

-c, --clean
           Clean up leftover work files and directories after a successful build.


I like this option, since it only removes the pkg and src folder if the build was successful. Downloaded files and the pkg.tar.xz stays obviously.


I would also add -C for even more cleaning. But I guess most people build in tmpfs, so most of the stuff is cleared at shutdown.

-C, --cleanbuild
           Remove the $srcdir before building the package.

makes sense to put that in Step 4 pt 1; building will fail if $srcdir is present.


4 posts were split to a new topic: Why install packages instead of running installer script?

Why install packages instead of running installer script?

The -C option don’t mean more cleaning. It will only remove a src Folder, if there is one, before the build starts. After the packages are created, the src and pkg folder stays.
The -c option cleans after a build, so you don’t need the -C option, except the build fails.


Thanks for this.

Imho it would also be very helpfull if somebody wants to switch back to the original package.
So would you please add an extra point how to switch back.
Thanks in advance.


For switching back, just install the packages with pacman -S.

For example, you use Linux 4.12 and did run Step 4 part 2 as described, do

pacman -S nvidia-utils mhwd-nvidia linux412-nvidia

If there is a question about downgrade, answer with yes.


Yes, you’re right. The -C option has become a habit for me because I often had failed builds while experimenting…


On thing that maybe should also included in the tutorial is building lib32-nvidia-utils or at least mentioned. If you run x86_64 and want play games with Steam, lib32-nvidia-utils is needed.
Since lib32-nvidia-utils doesn’t depend on nvidia-utils, there is no notification/errror that lib32-nvidia-utils is to old. Steam don’t start if the 32bit and 64bit versions are different.