New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use a NixOS module for generating the gdk-pixbuf loaders cache. #42562
Conversation
cc @jtojnar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is definitely nicer than the current solution.
In the future, we might want to consider something like #42176 (comment), though that would require patching gdk-pixbuf
to support multiple files in the environment variable.
Fixes issue NixOS#33231 and makes it possible to enable Plasma and KDE at the same time. Previously, this worked like this: - The gdk-pixbuf package comes with a cache file covering the modules bundled with gdk-pixbuf. - The librsvg package comes with a cache covering modules from gdk-pixbuf as well as librsvg. - plasma5 and xfce modules set the environment variable GDK_PIXBUF_MODULE_FILE to the one from librsvg, so that SVG was supported in addition to the formats supported by gdk-pixbuf. However if both were enabled a configuration conflict would result (despite setting to the same value). While this sort of worked (ignoring the conflict which perhaps could be hacked around), it is unscalable and a hack, as there would be a real problem when one wanted to add a third package that supports additional image formats. A new NixOS module (gdk-pixbuf) is added with a configuration option (modulePackages) that other modules use to request specific packages to be included in the loaders cache. When any package is present in the list, the module generates a system-wide loaders cache which includes the requested packages (and always gdk-pixbuf itself), and sets the environment variable GDK_PIXBUF_MODULE_FILE to point to the generated cache file. The plasma5 and xfce modules are updated to add librsvg to modulePackages instead of setting GDK_PIXBUF_MODULE_FILE. Note that many packages create wrappers that set GDK_PIXBUF_MODULE_FILE, some directly to the one from librsvg. Therefore this change does not change the existing hack in the librsvg package which ensures that file is generated. This change aims only to solve the conflict in the global environent variable configuration.
I have updated this according to comments from @jtojnar and tested on nixos-unstable. Note that if this is backported to 18.03, moduleDir will need to be added to gdk_pixbuf or hardcoded in the service like it used to be. |
Why is this not being merged? I have been using this for months and see no problems, and it solves the very real problem of not being able to use KDE apps from Xfce. |
Have the same problem. How can I use this solution under
? |
@s9gf4ult You need to checkout the nixos-18.09 branch from the nixpkgs-channels repository, cherry-pick the patch (which was merged to master already) and then do nixos-rebuild using that nixpkgs repository. Sorry I can't provide specific commands right now, if you ask in the #nixos channel on IRC someone should be able to help you out. |
This pull request has been mentioned on Nix community. There might be relevant details there: https://discourse.nixos.org/t/curious-gtk-issue-with-anydesk-svg-pixbuf-loader/1736/2 |
This pull request has been mentioned on Nix community. There might be relevant details there: https://discourse.nixos.org/t/curious-gtk-issue-with-anydesk-svg-pixbuf-loader/1736/3 |
We might want to filter variables like these from |
Interesting. This must be a general problem, surely we have other cases of environment variables leading to architecture-specific libraries (one just needs to look at environment variables in a desktop session, anything that contains PLUGIN is especially suspect), but I guess in many cases architecture mismatch is handled gracefully. In this case GDK really has no way to know the entire cache file is useless, it would only get an error when it tries to load a plugin.
I don't get your point about filtering, if we don't want it, we don't set it (but reintroduce the bugs that it fixed). |
The main issue with the variables is that they are problematic even on the same architecture. QT is notorious for this issue. There is simply no guarantee that the variable will not crash your system. Projects like GStreamer solve it by maintaining a stable ABI and gdk_pixbuf did the same but it still broke when a bug was fixed in 2.38. I do not think anybody ever considered multiarch, I certainly did not. Perhaps we could patch
Yes that is what I meant. |
Actually what I would do is to patch only 32-bit builds of the |
That is another possibility but it might be confusing. Wrapping is also the only way to prevent impurities like #54278 |
But with wrapping there are other issues:
|
Lots of apps are already wrapped to set Maybe we should somehow include the SVG loader inside the gdk_pixbuf package (or a wrapped package that everything uses) so that anything that uses gdk_pixbuf automatically gets SVG support and this mess with |
Fixes issue #33231 and makes it possible to enable Plasma and KDE at the same time.
Previously, this worked like this:
with gdk-pixbuf.
well as librsvg.
to the one from librsvg, so that SVG was supported in addition to the
formats supported by gdk-pixbuf. However if both were enabled a configuration
conflict would result (despite setting to the same value).
While this sort of worked (ignoring the conflict which perhaps could be hacked
around), it is unscalable and a hack, as there would be a real problem when one
wanted to add a third package that supports additional image formats.
A new NixOS module (gdk-pixbuf) is added with a configuration option
(modulePackages) that other modules use to request specific packages to be
included in the loaders cache. When any package is present in the list, the
module generates a system-wide loaders cache which includes the requested
packages (and always gdk-pixbuf itself), and sets the environment variable
GDK_PIXBUF_MODULE_FILE to point to the generated cache file.
The plasma5 and xfce modules are updated to add librsvg to modulePackages
instead of setting GDK_PIXBUF_MODULE_FILE.
Note that many packages create wrappers that set GDK_PIXBUF_MODULE_FILE,
some directly to the one from librsvg. Therefore this change does not
change the existing hack in the librsvg package which ensures that
file is generated. This change aims only to solve the conflict in the
global environent variable configuration.
Motivation for this change
Could not enable XFCE and Plasma at the same time. I confirm that with this change, I can enable both and then use Thunar from a Plasma session. I also confirm that the GDK_PIXBUF_MODULE_FILE enavironment variable is set correctly to the generated cache file and that the latter appears to be correct, listing image formats from both xdg-pixbuf modules and SVG from librsvg.
I suggest that this also be backported to 18.03 because the inability to use XFCE apps in KDE is pretty annoying and a regression from 17.09. Note that XFCE apps do not work in KDE correctly when the XFCE desktop is not enabled.
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)