Build Error: Missing cairo-xlib Package

Hello everyone,

I’m encountering a build error while trying to update my NixOS system. The logs indicate that the build process fails due to a missing package. Here’s a summary of the last 30 log lines:

checking if g++ static flag -static works… no
checking if g++ supports -c -o file.o… yes
checking if g++ supports -c -o file.o… (cached) yes
checking whether the g++ linker (ld -m elf_x86_64) supports shared libraries… yes
checking dynamic linker characteristics… (cached) GNU/Linux ld.so
checking how to hardcode library paths into programs… immediate
configure: creating ./config.lt
config.lt: creating libtool
checking for special C compiler options needed for large files… no
checking for _FILE_OFFSET_BITS value needed for large files… no
checking dependency style of gcc… none
checking for nm… /nix/store/lbk30k56awz9vz9qpid93fkjns0xwlhd-gcc-wrapper-13.3.0/bin/nm
checking whether to enable maintainer-specific portions of Makefiles… yes
checking for some Win32 platform… no
checking whether build environment is sane… yes
checking for library containing strerror… none required
checking whether make sets $(MAKE)… (cached) yes
checking pkg-config is at least version 0.9.0… yes
checking for BASE_DEPENDENCIES… yes
checking for CAIRO_BACKEND… no
configure: error: Package requirements (cairo-xlib >= 1.6) were not met:

No package ‘cairo-xlib’ found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables CAIRO_BACKEND_CFLAGS
and CAIRO_BACKEND_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
For full logs, run ‘nix log /nix/store/1c7mqvhawq1xhzdxxa1zwi01xx4ls3qd-gtk±2.24.33.drv’.

Error Explanation:

The key issue here is the error message:

configure: error: Package requirements (cairo-xlib >= 1.6) were not met:
No package ‘cairo-xlib’ found

System Info:

 - system: `"x86_64-linux"`
 - host os: `Linux 6.10.0, NixOS, 24.11 (Vicuna), 24.11.20240716.ad0b5ee`
 - multi-user?: `no`
 - sandbox: `yes`
 - version: `nix-env (Nix Super) 2.22.0pre20240705_1b14f2e`
 - channels(root): `"nixos-23.05"`
 - nixpkgs: `/nix/store/70y8v9qfn34sdfsnwh3l9772lk4rpfiy-source`

I’ve noticed that my system is currently using an older fork of Nix from a previous configuration. Although I’ve updated Nix in my flakes to a newer version, I’m encountering build errors when trying to switch to this updated configuration.

How can I remove the older version of Nix from my system to ensure that the new configuration takes effect properly?

Barring serious bugs, the version of Nix should have no effect on how Nixpkgs is evaluated. Unless you pinned Nix, it will get updated when you rebuild and switch to the config from the updated flake.

These kind of build errors typically occur because something in Nixpkgs is broken.

Commonly, a package A depends on some other package B but does not declare the dependency in its package expression, instead relying on some other dependency C propagating it. Then when the C package removes the propagation of B, A no longer has B available and fails to build.

Though, in this case, it looks like you might be using environment.noXlibs NixOS option, which, in my opinion, is broken on principle. Try disabling that.