Nonguix NVIDIA failing to build because of mesa

Hello, I am trying to install the nvidia drivers on a headless guix server so that I can host a jellyfin container. The machine has an nvidia gpu and no integrated graphics.

For context, the system was building and worked before I tried making the changes to my config to add nvidia drivers. Also, mesa was failing to build after my initial reconfigure so I did a guix pull.

I see this from reconfigure (before and after the pull):

building /gnu/store/2nr23gc8rady4gkxzk690zy6sfcj3v1b-mesa-25.1.3.drv...
\ 'configure' phasebuilder for `/gnu/store/2nr23gc8rady4gkxzk690zy6sfcj3v1b-mesa-25.1.3.drv' failed with exit code 1
build of /gnu/store/2nr23gc8rady4gkxzk690zy6sfcj3v1b-mesa-25.1.3.drv failed
View build log at '/var/log/guix/drvs/2n/r23gc8rady4gkxzk690zy6sfcj3v1b-mesa-25.1.3.drv.gz'.
cannot build derivation `/gnu/store/llsl76kx0chq0pblrm1d0wy2hk65zc2i-nvda-570.18.drv': 1 dependencies couldn't be built
building /gnu/store/cjxp5a8sa71n0py3wncv0z9cmrlfywvj-nvidia-firmware-570.181.drv...
cannot build derivation `/gnu/store/dc41hmrr6gmrpavvj1is5gg4q10y5fyj-profile.drv': 1 dependencies couldn't be built
building /gnu/store/7agqnv9jx7w6ikszxasmrkni2108xkp6-raw-initrd.drv...
cannot build derivation `/gnu/store/75c1145znch41vz1sksknmbdz2hgfrx3-system.drv': 1 dependencies couldn't be built
guix system: error: build of `/gnu/store/75c1145znch41vz1sksknmbdz2hgfrx3-system.drv' failed

I looked at the build log indicated and I see this:

Library m found: YES
Message: libdrm 2.4.121 needed because amdgpu has the highest requirement
Run-time dependency libdrm_intel found: YES 2.4.124
Run-time dependency libdrm_amdgpu found: YES 2.4.124
Run-time dependency libdrm found: YES 2.4.124
Did not find CMake 'cmake'
Found CMake: NO
Run-time dependency libudev found: NO (tried pkgconfig and cmake)

../mesa-25.1.3/meson.build:1767:13: ERROR: Failed running '/gnu/store/kl1j1g1p4mv3xz1x19izpbfjilyfrxc3-llvm-for-mesa-18.1.8/b\
in/llvm-config', binary or interpreter not executable.
Possibly wrong architecture or the executable bit is not set.

I’m not sure why it is trying to build mesa as this is a headless system. I printed out the %base-packages and there were no mesa packages in there.

These are the changes I made to my config.scm to install and use the nvidia drivers:

(use-modules (gnu)
...
+             (nongnu packages nvidia)                                                                                        
+             (nongnu services nvidia)        
+             (nongnu packages nvidia)                                                                                        
+             (nongnu services nvidia)    
...
)
-(use-service-modules networking ssh containers dbus desktop)                                                                 
-(use-package-modules screen ssh)                                                                                             
+(use-service-modules linux networking ssh containers dbus desktop)                                                           
+(use-package-modules linux screen ssh)   
   (kernel-arguments (list "console=ttyS0,115200"                                                                             
                           "systemd.unified_cgroup_hierarchy=1"                                                               
-                          "cgroup_no_v1=all"))                                                                               
+                          "cgroup_no_v1=all"                                                                                 
+                          "modprobe.blacklist=nouveau"                                                                       
+                          "nvidia_drm.modeset=1"))      
  (packages (cons* screen
                   emacs-no-x
                   emacs-magit
...
+                   mesa-for-nvda                                                                                             
+                   nvda                                                                                                      
+                   nvidia-driver                                                                                             
                    %base-packages))   
  (services (append (list
...
+                     (service nvidia-service-type) 
...
                     )
                     %base-services)))

Entire config.scm
(use-modules (gnu)
             (gnu packages emacs)
             (gnu packages emacs-xyz)
             (gnu packages containers)
             (gnu packages certs)
             (gnu packages perl)
             (gnu packages commencement)
             (gnu packages autotools)
             (gnu packages cmake)
             (gnu packages linux)
             (gnu packages python)
             (gnu packages rsync)
             (gnu packages freedesktop)
             (gnu packages version-control)
             (gnu packages mtools)
             (gnu packages base)
             (gnu packages nfs)
             (gnu packages gl)
             (gnu packages admin)
             (gnu services networking)
             (gnu services base)
             (nongnu packages linux)
             (nongnu packages nvidia)
             (nongnu services nvidia)
             (gnu system)
             (gnu system shadow)
             (gnu system file-systems)
             (gnu system accounts)
             (gnu services containers)
             (gnu services dbus)
             (gnu services desktop)
             (guix packages)
             (guix utils)
             (srfi srfi-1)
             )

(use-service-modules linux networking ssh containers dbus desktop)
(use-package-modules linux screen ssh)

(define (get-admin-user user-list)
  (find (lambda (x)
          (equal? (user-account-comment x) "Administrator"))
        user-list))

(define (get-current-admin user-list)
  (user-account-name (get-admin-user user-list)))

(define %homelab-user-accounts
  (list
   (user-account
    (name "jesse")
    (comment "Administrator")
    (group "users")
    (supplementary-groups '("wheel"
                            "audio" "video"
                            "netdev" "cgroup" )))
   ))
(define %iptables-rules
  ;; Made this by doing the suggested iptables cli commands                                                                   
  ;; then doing iptables-save > iptables.txt                                                                                  
  ;; then copying that to here                                                                                                
  "# Generated by iptables-save v1.8.11 on Sun Aug 10 23:25:52 2025                                                           
*nat                                                                                                                          
:PREROUTING ACCEPT [2:300]                                                                                                    
:INPUT ACCEPT [2:300]                                                                                                         
:OUTPUT ACCEPT [0:0]                                                                                                          
:POSTROUTING ACCEPT [0:0]                                                                                                     
-A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080                                                            
-A PREROUTING -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 8443                                                           
-A PREROUTING -p tcp -m tcp --dport 222 -j REDIRECT --to-ports 8222                                                           
COMMIT                                                                                                                        
# Completed on Sun Aug 10 23:25:52 2025                                                                                       
# Generated by iptables-save v1.8.11 on Sun Aug 10 23:25:52 2025                                                              
*filter                                                                                                                       
:INPUT ACCEPT [136:33123]                                                                                                     
:FORWARD ACCEPT [0:0]                                                                                                         
:OUTPUT ACCEPT [32:3402]                                                                                                      
COMMIT                                                                                                                        
# Completed on Sun Aug 10 23:25:52 2025                                                                                       
")
(operating-system
  (kernel linux)
  (firmware (list linux-firmware))
  (host-name "homelab")
  (timezone "America/Detroit")
  (locale "en_US.utf8")

  (bootloader (bootloader-configuration
                (bootloader grub-efi-bootloader)
                (targets '("/boot"))))
  (kernel-arguments (list "console=ttyS0,115200"
                          "systemd.unified_cgroup_hierarchy=1"
                          "cgroup_no_v1=all"
                          "modprobe.blacklist=nouveau"
                          "nvidia_drm.modeset=1"))

  (file-systems (cons* (file-system
                        (device (file-system-label "system-root"))
                        (mount-point "/")
                        (type "btrfs"))
                       (file-system
                        (device (file-system-label "ESP"))
                        (mount-point "/boot")
                        (type "vfat"))
                       %base-file-systems
                       ))

  (users (append
          %homelab-user-accounts
          %base-user-accounts))

  (packages (cons* screen
                   emacs-no-x
                   emacs-magit
                   emacs-multi-vterm
                   emacs-geiser-guile
                   emacs-geiser
                   emacs-vterm
                   perl
                   libtool
                   gcc-toolchain
;;                 make                                                                                                       
                   cmake
                   iptables
                   python
                   git
                   rsync
                   rsync
                   udisks
                   lvm2
                   mtools
                   podman podman-compose
                   nfs-utils
                   smartmontools
                   lshw
                   mesa-for-nvda
                   nvda
                   nvidia-driver
                   %base-packages))

  (services (append (list
                     (service openssh-service-type
                              (openssh-configuration
                               (openssh openssh-sans-x)
                               (port-number xxxx)))
                     (service static-networking-service-type
                              (list (static-networking
                                     (addresses
                                      (list (network-address
                                             (device "eno1")
                                             (value "xxx.xxx.xxx.xxx/xx"))))
                                     (routes
                                      (list (network-route
                                             (destination "default")
                                             (gateway "xxx.xxx.xxx.xxx"))))
                                     (name-servers '("xxx.xxx.xxx.xxx")))
                                     ))
                     ;; Services for proprietary NVIDIA drivers                                                               
                     (service nvidia-service-type)
                     ;; Services for podman ___________________________________________                                       
                     (service dbus-root-service-type)
                     (service elogind-service-type)
                     (service iptables-service-type
                              (iptables-configuration
                               (ipv4-rules (plain-file "iptables.rules" %iptables-rules)
                                           )))
                     (service rootless-podman-service-type)
                     (simple-service 'homelab-subids
                                     subids-service-type
                                     (subids-extension
                                      (subgids
                                       (list
                                        (subid-range (name (get-current-admin
                                                            %homelab-user-accounts)))))
                                      (subuids
                                       (list
                                        (subid-range (name (get-current-admin
                                                            %homelab-user-accounts))
                                                     (start 100700))))))
                     )
                     %base-services)))
channels.scm
(list (channel
        (name 'guix)
        (url "https://git.savannah.gnu.org/git/guix.git")
        (branch "master")
        (introduction
          (make-channel-introduction
            "9edb3f66fd807b096b48283debdcddccfea34bad"
            (openpgp-fingerprint
              "BBB0 2DDF 2CEA F6A8 0D1D  E643 A2A0 6DF2 A33A 54FA"))))
      (channel
        (name 'nonguix)
        (url "https://gitlab.com/nonguix/nonguix")
        (branch "master")
        (introduction
          (make-channel-introduction
            "897c1a470da759236cc11798f4e0a5f7d4d59fbc"
            (openpgp-fingerprint
              "2A39 3FFF 68F4 EF7A 3D29  12AF 6F51 20A0 22FB B2D5")))))

For what it’s worth, I removed all of those changes to make sure my system reconfigure worked. It did. Then I just added nvidia-driver in to the packages list and that is when mesa-25.1.3 is being pulled in and I get the same error.

So now I know who is pulling it in but I’m not sure if the fix is with the package or with something I’m doing in my config.

I’ve also tried throwing all of my packages into a variable:

(define %homelab-packages
  (cons* screen
         emacs-no-x
         emacs-magit
         emacs-multi-vterm
         emacs-geiser-guile
         emacs-geiser
         emacs-vterm
         perl
         libtool
         gcc-toolchain
         cmake
         iptables
         python
         git
         rsync
         udisks
         lvm2
         mtools
         podman podman-compose
         nfs-utils
         smartmontools
         lshw                                                                                                   
         nvidia-driver
         %base-packages))

Then using the replace-mesa function provided by nongnu packages nvidia:

(operating-system
;; ...
  (packages (replace-mesa %homelab-packages))
;; ...
)

Doing a system reconfigure is still pulling mesa and it is failing to build in the same way:

Did not find CMake 'cmake'
Found CMake: NO
Run-time dependency libudev found: NO (tried pkgconfig and cmake)

../mesa-25.1.3/meson.build:1767:13: ERROR: Failed running '/gnu/store/kl1j1g1p4mv3xz1x19izpbfjilyfrxc3-llvm-for-mesa-18.1.8/b\
in/llvm-config', binary or interpreter not executable.
Possibly wrong architecture or the executable bit is not set.

Maybe mesa needs libudev? That might be my real issue here. I guess I just expected the package to be built to be mesa-for-nvidia because of my usage of replace-mesa.

I tried making a package variant that deleted the gui related libraries, since I’m headless:

(define-module (homelab packages nvidia)
  #:use-module (nongnu packages nvidia)
  #:use-module (nongnu packages linux)
  #:use-module (guix packages)
  #:use-module (guix utils))


(define-public nvidia-driver-headless
  (package
    (inherit nvidia-driver)
    (name "nvidia-driver-headless")
    (synopsis "Proprietary NVIDIA driver (headless variant)")
    (description
     "This variant of the proprietary NVIDIA driver removes dependencies                                                      
on X11, Wayland, Mesa, and EGL backends.")
    (inputs
     (modify-inputs (package-inputs nvidia-driver)
                    (delete "mesa-for-nvda"
                            "egl-gbm"
                            "egl-x11"
                            "egl-wayland"
                            "wayland")))))

I added this to my list of packages, no other changes to my config.scm. On a system reconfigure I still get the issue that mesa fails to build:

substitute: looking for substitutes on 'https://bordeaux.guix.gnu.org'... 100.0%
substitute: looking for substitutes on 'https://ci.guix.gnu.org'... 100.0%
The following derivations will be built:
  /gnu/store/2nr23gc8rady4gkxzk690zy6sfcj3v1b-mesa-25.1.3.drv
  /gnu/store/zvfvq48rnbz5y22cldnplnfs3473xpdl-nvidia-driver-headless-570.181.drv
  /gnu/store/852d418gbfzckvwgcaqi56952xqwrp1c-profile.drv
  /gnu/store/mwkq2wpbrgflbpqzvlslp5xjlgv4gvgm-provenance.drv
  /gnu/store/2zb0wsh1gcdp3rfqadzz0fjdy5w32cx6-system.drv
  /gnu/store/ddkhb7fbi7f60s9asnzr4bk0a7818jdn-grub.cfg.drv

building /gnu/store/mwkq2wpbrgflbpqzvlslp5xjlgv4gvgm-provenance.drv...
building /gnu/store/2nr23gc8rady4gkxzk690zy6sfcj3v1b-mesa-25.1.3.drv...
/ 'configure' phasebuilder for `/gnu/store/2nr23gc8rady4gkxzk690zy6sfcj3v1b-mesa-25.1.3.drv' failed with exit code 1
build of /gnu/store/2nr23gc8rady4gkxzk690zy6sfcj3v1b-mesa-25.1.3.drv failed
View build log at '/var/log/guix/drvs/2n/r23gc8rady4gkxzk690zy6sfcj3v1b-mesa-25.1.3.drv.gz'.
cannot build derivation `/gnu/store/zvfvq48rnbz5y22cldnplnfs3473xpdl-nvidia-driver-headless-570.181.drv': 1 dependencies couldn't be built
cannot build derivation `/gnu/store/852d418gbfzckvwgcaqi56952xqwrp1c-profile.drv': 1 dependencies couldn't be built
cannot build derivation `/gnu/store/2zb0wsh1gcdp3rfqadzz0fjdy5w32cx6-system.drv': 1 dependencies couldn't be built
guix system: error: build of `/gnu/store/2zb0wsh1gcdp3rfqadzz0fjdy5w32cx6-system.drv' failed

The inputs for the nonguix nvidia-driver are:

   (native-inputs (list patchelf-0.16))
    (inputs
     (list egl-gbm
           egl-wayland
           egl-x11
           `(,gcc "lib")
           glibc
           mesa-for-nvda
           openssl
           openssl-1.1
           wayland))

After the ones I deleted, the ones left are (gcc "lib"), glibc, openssl, and openssl-1.1. I don’t see where mesa is being pulled in.