NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
16.46k stars 12.95k forks source link

xorg.libX11 - runtime dependency on xorg.libXcursor? #24137

Open pbogdan opened 7 years ago

pbogdan commented 7 years ago

Issue description

I've ran into a strange situation where certain applications wouldn't respect my mouse cursor settings. An example of that is rxvt_unicode. Stracing urxvt shown the process trying to load libXcursor library which seemed relevant, despite urxvt itself not being linked against it. Some further digging shown that libX11, on which urxvt depends, seems to try loading it dynamically at runtime, and once I installed xorg.libXcursor the issue went away. Is the requirement of manual installation of libXcursor the expected behaviour?

Steps to reproduce

  1. Install rxvt_unicode package.
  2. Customise any cursor settings for example by adding the following to .Xdefaults:
Xcursor.size:  48
  1. Run
$ xrdb .Xdefaults
  1. Launch urxvt from the same shell session.

Technical details

hhomar commented 6 years ago

Does this still work for you? I'm running into the same problem, but xorg.libXcursor is installed.

I can workaround the problem by adding the libXcursor path to LD_LIBRARY_PATH, but that seems like a horrible hack.

pbogdan commented 6 years ago

I changed my configuration quite a bit since reporting but as is I'm using the same LD_LIBRARY_PATH hack on NixOS 17.03, but specified in global configuration.nix. I can only suspect I had something similar previously and failed to mention that in the initial report. Apologies for that.

pbogdan commented 6 years ago

@hhomar also, forgot to ask - have you seen this issue in applications other than urxvt? It doesn't seem like a wide spread problem so perhaps it would make sense to fix the individual applications on case by case basis.

hhomar commented 6 years ago

lightdm doesn't work without the hack either. I haven't seen the problem in any other applications so far.

I was hoping to find a way to fix all applications, but the only thing I could come up is:

diff --git a/pkgs/servers/x11/xorg/overrides.nix b/pkgs/servers/x11/xorg/overrides.nix
index c7a4ff20a7..132f3ce720 100644
--- a/pkgs/servers/x11/xorg/overrides.nix
+++ b/pkgs/servers/x11/xorg/overrides.nix
@@ -85,6 +85,9 @@ in
     preConfigure = setMalloc0ReturnsNullCrossCompiling + ''
       sed 's,^as_dummy.*,as_dummy="\$PATH",' -i configure
     '';
+    postPatch = ''
+      substituteInPlace src/CrGlCur.c --replace "libXcursor.so.1" "/run/current-system/sw/lib/libXcursor.so.1"
+    '';
     postInstall =
       ''
         # Remove useless DocBook XML files.

The problem with that is it requires libXcursor to be a system package and for the user to know to do that. It doesn't seem any better than using using LD_LIBRARY_PATH.

Atemu commented 5 months ago

AFAICT, this issue is not resolved. See https://dnr.im/tech/broken-cursors/

cc @dnr

dnr commented 5 months ago

Thanks for linking to my post.

The post describes a series of hideous hacks to fix the problem for me, and is limited to solutions that don't require me to rebuild the world. They're clearly not appropriate for Nixpkgs, but it's not obvious how to fix it in Nixpkgs because of the circular dependency.

I think my best proposal would be:

If people think this has a shot of getting accepted, I can test it out and make a PR. I'm way out of the loop so not sure who to ask about this stuff.

dnr commented 5 months ago

Just for fun I tried that idea of getting both .so files in the same package: turns out libXcursor depends directly on libX11, but it also depends on libXrender which depends on libX11, i.e. a three-package cycle. So it's looking less likely that it can work.

For completeness, a few other references in nixpkgs: https://github.com/NixOS/nixpkgs/blob/434dd13b25bfe1db97a7bb32cf772f3493416bc3/pkgs/applications/networking/instant-messengers/ripcord/default.nix#L53 https://github.com/NixOS/nixpkgs/blob/434dd13b25bfe1db97a7bb32cf772f3493416bc3/pkgs/development/libraries/qt-5/modules/qtbase.nix#L218 (used here: https://github.com/NixOS/nixpkgs/blob/434dd13b25bfe1db97a7bb32cf772f3493416bc3/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0007-qtbase-xcursor.patch#L19)

Atemu commented 5 months ago

One idea I had would be to build the packages each on their own (as is done currently) but then copy them together into a single "libX11" and adjust their rpaths via patchelf.

dnr commented 5 months ago

I tried to do it in a single derivation, but yeah, multiple derivations may be easier. Would that work with the xrender cycle, though? You'd have the following dependencies:

But you couldn't get libxrender to depend on libx11+xcursor.