linuxPackages.nvidia_x11.libXNVCtrl: make the shared library available#312811
linuxPackages.nvidia_x11.libXNVCtrl: make the shared library available#312811SomeoneSerge merged 3 commits intoNixOS:masterfrom aidalgol:libxnvctrl-shared
Conversation
ConnorBaker
left a comment
There was a problem hiding this comment.
One minor nit; I can try the builds later to verify they build.
Do you have an easy way to verify this is working as intended?
Also, would you mind adding yourself to the list of maintainers for pkgs/os-specific/linux/nvidia-x11/settings.nix?
There was a problem hiding this comment.
Looking at https://github.com/NVIDIA/nvidia-settings/blob/4e4bb3fecbbdd902d6f4bc6bbfb9902043c5c7f6/src/libXNVCtrl/Makefile#L39-L53, it seems that we could build the .so just by invoking make with appropriate arguments. I think that'd be more maintainable than patching Makefile per-release.
If we wish to build both the static and the shared object in a single derivation we'd still have to define a custom buildPhase, but I think that's OK.
There was a problem hiding this comment.
There's no make rule for a .so file in xnvctrl.mk (or anywhere that I can see), so I don't think we can do this via make arguments. We could possibly just bypass make entirely and invoke the commands directly in a custom buildPhase, but I'm not sure whether that would be more maintainable.
There was a problem hiding this comment.
Oh I didn't notice the $(AR) part, I was naive to think they had some kind of a generic rule for linkage...
There was a problem hiding this comment.
I'd still like to get rid of the conditional patches. A part of the diff doesn't seem to be essential to the derivation, e.g. the clean (no-op for nix) and all (we have makeFlags/makeTargets for that) rules. Maybe omitting those we could have a single patch that successfully applies to all releases: adding nothing but the .so rule.
There was a problem hiding this comment.
I was able to simplify down to two patches, because xnvctrl.mk does not exist in the 3xx versions.
The program I was trying to get to work with my nvidia GPU was MangoHUD, so running Before changes: ❯ mangohud vkcube
Selected GPU 0: NVIDIA GeForce RTX 3080, type: DiscreteGpu
[2024-05-20 06:44:07.254] [MANGOHUD] [error] [loader_nvctrl.cpp:39] Failed to open 64bit libXNVCtrl.so.0: libXNVCtrl.so.0: cannot open shared object file: No such file or directory
[2024-05-20 06:44:07.254] [MANGOHUD] [error] [nvctrl.cpp:48] XNVCtrl loader failed to loadAfter changes: ❯ mangohud vkcube
Selected GPU 0: NVIDIA GeForce RTX 3080, type: DiscreteGpu(With |
SomeoneSerge
left a comment
There was a problem hiding this comment.
I've some general comments left, in the line of "are we solving the right problem":
- It seems that patching
Makefiles takes approximately the same amount of code as shipping our own ad hocCMakeLists.txtwould have... - It seems that upstream does not distribute shared libraries, so it feels kind of arbitrary that MangoHUD should use it as one.
- Further on MangoHUD, these probably should be in
buildInputs:nixpkgs/pkgs/tools/graphics/mangohud/default.nix
Lines 190 to 194 in dbeb624
That said, if you @aidalgol are convinced this is the way to address your use-case, I'll merge
Do you mean for all of
MangoHUD is not the only package in nixpkgs that references
But I don't know whether any of those try to link dynamically. It sounds as if Conky does: Installing libxnvctrl (525.60.11-2) breaks dependency ‘libXNVCtrl.so=0-64’ required by conky. Looking at other Linux distributions, at least Arch patches
That I'm not too sure about. If someone is using |
libXNVCtrl
Seems like the patch belongs in NVIDA/nvidia-settings then, let's aim to eventually move it there. |
In that case, I would not be opposed to instead replacing the upstream
You mean upstream it? |
Yes
I'd be in favour of that. But also if we're upstreaming a patch, we'll want to switch to If you need time to choose but you're committed to following up on this, I can merge the current PR as a temporary fix |
|
I have submitted a PR upstream and have changed the |
There was a problem hiding this comment.
- Iirc the
pull/xxxx/commits/yyyyURL may get invalidated after force-pushing or even rebase-merging (I may be wrong) - The
fetchpatchnow has an updatedallrule, but the 3xx patch doesn't and the new commit omitsmakeTargets
There was a problem hiding this comment.
I think you're right. I thought that would make it robust against PR changes, but I think GitHub does invalidate commit URLs on a force push, at least after a while. I think I should back out this commit until the PR is merged.
The libXNVCtrl library is used by several programs in nixpkgs to get Nvidia GPU stats, and they all load the library dynamically, but the libXNVCtrl package only builds a static library. There is no build flag to enable this, so we have to patch the Makefile to produce a shared library. Based on a patch by @negativo17 for Fedora. https://github.com/negativo17/nvidia-settings/blob/master/nvidia-settings-libXNVCtrl.patch
| ''; | ||
| hardware.opengl = { | ||
| extraPackages = [ nvidia_x11.out ]; | ||
| extraPackages = [ nvidia_x11.out nvidia_x11.settings.libXNVCtrl ]; |
There was a problem hiding this comment.
I had another look at the derivation and it actually doesn't seem to depend on nvidia_x11, except through nvidia_x11.settingsVersion. This makes me question if we actually have to deploy this impurely rather than link directly
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin release-23.11
git worktree add -d .worktree/backport-312811-to-release-23.11 origin/release-23.11
cd .worktree/backport-312811-to-release-23.11
git switch --create backport-312811-to-release-23.11
git cherry-pick -x b57aa88291910689aeaa83ff40dd02c50ab8199b 4e353b67f667766b1c6489f23c20b920ab0c82f5 e8c66dc41dd95c70718ba9f5ab34e9ebe23e49c4 |
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin release-24.05
git worktree add -d .worktree/backport-312811-to-release-24.05 origin/release-24.05
cd .worktree/backport-312811-to-release-24.05
git switch --create backport-312811-to-release-24.05
git cherry-pick -x b57aa88291910689aeaa83ff40dd02c50ab8199b 4e353b67f667766b1c6489f23c20b920ab0c82f5 e8c66dc41dd95c70718ba9f5ab34e9ebe23e49c4 |
| ''; | ||
| hardware.opengl = { | ||
| extraPackages = [ nvidia_x11.out ]; | ||
| extraPackages = [ nvidia_x11.out nvidia_x11.settings.libXNVCtrl ]; |
There was a problem hiding this comment.
❗ This will break things. Depending on config ( useSettings or nvidiaSettings ) nvidia_x11.settings might be a empty set. See https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/os-specific/linux/nvidia-x11/generic.nix#L215
This should handle that case or be reverted.
Description of changes
The libXNVCtrl library is used by several programs in nixpkgs to get Nvidia GPU stats, and they all load the library dynamically, but the libXNVCtrl package only builds a static library. There is no build flag to enable this, so we have to patch the Makefile to produce a shared library. We then add the package to
hardware.opengl.extraPackagesin the NixOS modulehardware/video/nvidia.nixso that it is available on Nvidia-enabled systems.Based on a patch by @negativo17 for Fedora: https://github.com/negativo17/nvidia-settings/blob/master/nvidia-settings-libXNVCtrl.patch
Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.