NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
16.53k stars 13.02k forks source link

xorg.libXi pkg-config does not include xorg.libXfixes cflags #172748

Open IllustratedMan-code opened 2 years ago

IllustratedMan-code commented 2 years ago

Describe the bug

I have been trying to build the godot game engine using a flake. I was able to get a successful build working, but I had fork the project and add a env.ParseConfig("pkg-config xfixes --cflags") to their detect.py script (using the scons build system). This is strange, because there is already a pkg-config line for xi in their script env.ParseConfig("pkg-config xi --cflags --libs"). xi should also include the flags for xfixes.

More information can be found in this issue on the godot repository: https://github.com/godotengine/godot/issues/59913

Steps To Reproduce

Steps to reproduce the behavior:

  1. clone my flake repository from here: https://github.com/IllustratedMan-code/Godot-Flake
  2. make sure flakes are enabled
  3. run nix build

Expected behavior

I expected the pkg-config xi line to function normally by also including the flags for xfixes.

Notify maintainers

@TredwellGit @vcunat

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

his path will be fetched (0.00 MiB download, 0.00 MiB unpacked):
  /nix/store/qypk3gzaf4p5bhzmyzjmlycs8v2sdw2h-nix-info
copying path '/nix/store/qypk3gzaf4p5bhzmyzjmlycs8v2sdw2h-nix-info' from 'https://cache.nixos.org'...
 - system: `"x86_64-linux"`
 - host os: `Linux 5.15.32, NixOS, 22.05 (Quokka)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.9.0pre20220505_f4102de`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
akien-mga commented 1 year ago

To be clear, on Linux distros using the standard /usr/include path as default include path, the upstream X11 pkgconfig file is sufficient (example from Mageia):

$ cat /usr/include/X11/extensions/XInput2.h | grep Xfixes
#include <X11/extensions/Xfixes.h> /* PointerBarrier */
$ ls /usr/include/X11/extensions/Xfixes.h 
/usr/include/X11/extensions/Xfixes.h
$ cat /usr/lib64/pkgconfig/xi.pc 
prefix=/usr
exec_prefix=/usr
libdir=/usr/lib64
includedir=/usr/include

Name: Xi
Description: X Input Extension Library
Version: 1.8
Requires: inputproto
Requires.private: x11 xext xfixes
Cflags: -I${includedir}
Libs: -L${libdir} -lXi

A project using Xinput2 like Godot does, and parsing pkg-config --cflags --libs xi, will properly get -I/usr/include added which resolves <X11/extensions/Xfixes.h> fine.

And Mageia's package that provides Xinput2 does properly depend on Xfixes:

$ urpmq --requires lib64xi-devel
devel(libX11(64bit))
devel(libXext(64bit))
lib64xi6[== 1.8-2.mga9]
pkgconfig
pkgconfig(inputproto)
pkgconfig(x11)
pkgconfig(xext)
pkgconfig(xfixes)

So likewise, Nix's libXi should require libXfixes, and its pkgconfig file should be amended to point to the include path prefix for libXfixes so that the cross-dependency can be resolved.

akien-mga commented 1 year ago

I haven't checked the Nix libXi packaging, but for the record, it should likely also depend on libXext:

$ cat /usr/include/X11/extensions/XInput2.h | grep include.*extensions
#include <X11/extensions/XI2.h>
#include <X11/extensions/Xge.h>
#include <X11/extensions/Xfixes.h> /* PointerBarrier */

(Xge.h is from libXext)

It wasn't spotted as an issue for Nix users on Godot because we do use and thus have a dependency on libXext explicitly for other parts of the codebase.

There might be more similar intricate cross-dependencies among X11 extensions which would be worth reviewing. Otherwise X11 projects would basically need to overlink all X11 extensions to be safe, which defeats the purpose of these extensions being packaged separately.

Artturin commented 1 year ago

We already propagate libXfixes and libXext in libXi

xorg/overrides.nix

    propagatedBuildInputs = attrs.propagatedBuildInputs or [] ++ [ xorg.libXfixes xorg.libXext ];