Conversation
69ff19e to
78bb961
Compare
|
Sorry for the late reply, this got lost in my queue. I think this is reasonable compromise between performance and convenience for packaging. Primary concerns would be that gdk-pixbuf does not normally allow this so I am not sure how well does Some basic tests along the line of would go a long way in making sure this does not bring any unfortunate breakage, without having to rebuild the world. |
There was a problem hiding this comment.
I wonder if --prefix might be safer here. E.g. in case user has GDK_PIXBUF_MODULE_FILE in their environment containing ABI incompatible loaders (assuming the cache format is stable, first registered module for given file takes precedence, and modules are loaded lazily). But it is not clear to me what handles matching the image to a module, so 🤷♀️
|
I share your concern about the robustness of the patch. With some tests, hopefully we'll have a better idea of its vulnerabilities. About --suffix, I think (?) later entries in $GDK_PIXBUF_MODULE_FILE have precedence. In any case, the opposite precedence behavior seems to be the standard, and I agree modules included with the package should have precedence. So I'll change it to --prefix, and edit the patch to process the path in reverse order. I wonder if packaging procedures will have to change.
Seeing how many gtk programs there are, I imagine they behaviours have to stay. But it doesn't really indicate how we should design the interface for packaging more-than-one loaders.cache. Should we make all loader packages have setupHooks that append to $GDK_PIXBUF_MODULE_FILE, just like shared libraries do to $LD_LOADERS_PATH? But unlike shared libraries, modules often overlap: do we then need a way to specify their order? Though the vast majority of programs just need the standard librsvg/gdk-pixbuf to render GTK icons. Perhaps wrapGAppsHook can include them automatically, packages not directly calling gdk-pixbuf no longer need to explicitly include them in buildInputs (but it doesn't hurt), packages needing other loaders can manually wrap them (maintaining the librsvg-containing-gdk-pixbuf behaviour), and setupHooks can be eliminated. In any case, users will benefit from the ability to specify their own loaders. |
It is ¿well? documented that wrappers are always required.
Again, I would not worry about that. It is documented what
I think (Alternately, we might compile the
Yeah, with the ordering you mention, that will be unpredictable, especially since loaders can get into inputs via
Actually, that sounds reasonable too. For convenience, |
06da907 to
a10c7eb
Compare
67934bb to
04b9038
Compare
(will squash before committing)
will be squashed before merge
faa648f to
5390d5e
Compare
to do: tests for patched code will be squashed before merge
5390d5e to
ce9de7a
Compare
will be squashed before merging
ce9de7a to
1799c2c
Compare
|
Sorry for the delay. I've made some corrections, and added a simple test for gdk-pixbuf. |
1799c2c to
93369d8
Compare
will be squashed before merging
93369d8 to
a4e5e1e
Compare
|
Still need to modify |
| - []{#ssec-gnome-hooks-glib} `glib` setup hook will populate `GSETTINGS_SCHEMAS_PATH` and then `wrapGAppsHook` will prepend it to `XDG_DATA_DIRS`. | ||
|
|
||
| - []{#ssec-gnome-hooks-gdk-pixbuf} `gdk-pixbuf` setup hook will populate `GDK_PIXBUF_MODULE_FILE` with the path to biggest `loaders.cache` file from the dependencies containing [GdkPixbuf loaders](#ssec-gnome-gdk-pixbuf-loaders). This works fine when there are only two packages containing loaders (`gdk-pixbuf` and e.g. `librsvg`) – it will choose the second one, reasonably expecting that it will be bigger since it describes extra loader in addition to the default ones. But when there are more than two loader packages, this logic will break. One possible solution would be constructing a custom cache file for each package containing a program like `services/x11/gdk-pixbuf.nix` NixOS module does. `wrapGAppsHook` copies the `GDK_PIXBUF_MODULE_FILE` environment variable into the produced wrapper. | ||
| - []{#ssec-gnome-hooks-gdk-pixbuf} `wrapGAppsHook` will automatically prepend `GDK_PIXBUF_MODULE_FILE` with modules from `gdk-pixbuf` and `librsvg`. To include additional gdk-pixbuf modules, set `extraGdkPixbufModules` with an array of packages. |
There was a problem hiding this comment.
Maybe add []{#setup-hook-gdk-pixbuf} so that the deleted setup hook section points here as well.
| '' | ||
| ); | ||
|
|
||
| # Stopgap as no modules have been packaged yet |
There was a problem hiding this comment.
I think it is desirable to use fake modules here even after they have been packaged to allow testing wrapGAppsHook changes with minimal changes.
| mkdir -p $lib/$(dirname ${gdk-pixbuf.cacheFile}) | ||
| touch $lib/${gdk-pixbuf.cacheFile} |
There was a problem hiding this comment.
To clean this up, it might be nice to move this to the sample-project and then use installFlags = [ "loaders.cache" ];.
There was a problem hiding this comment.
I think they should be separate, since the sample-project is wrapped by the setup hook and the mock loader is an input for the wrapper.
There was a problem hiding this comment.
Sorry, I meant move it to the Makefile in sample-project, then you will be able to use src & installFlags.
pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/default.nix
Outdated
Show resolved
Hide resolved
pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/default.nix
Outdated
Show resolved
Hide resolved
pkgs/development/libraries/gdk-pixbuf/multiple-module-files-test/default.nix
Outdated
Show resolved
Hide resolved
| @@ -1,17 +0,0 @@ | |||
| findGdkPixbufLoaders() { | |||
There was a problem hiding this comment.
One use case that still is ¿not covered? is the use of loaders during build/checkPhase. Previously findGdkPixbufLoaders had us covered but now we need to set the environment variable manually. But maybe it is okay? Edit: Actually, that makes using nix-shell inconvenient compared to just nix-shell -I nixpkgs=$PWD -p gdk-pixbuf -p librsvg --run 'gdk-pixbuf-thumbnailer test.svg test.png'. So perhaps we might actually retain this setup hook just doing addToSearchPath.
There was a problem hiding this comment.
If we set GDK_PIXBUF_MODULE_FILE for the user, then should we also return to wrapGAppsHook drawing from the build-time environment variable, so that what works in the build environment also works in the final package?
There was a problem hiding this comment.
Also, would not being able to control order be an issue?
There was a problem hiding this comment.
I can imagine some use cases for wanting specific order but they probably be rare so I would not bother with that. People can always juggle with the variable contents if they need it.
Though I am split on having a separate attribute vs. using buildInputs. On one hand, separate attribute offers a finer control and the behaviour is more clear by the fact of being explicit. On the other hand all other wrappers just pick stuff up from inputs so not doing that for loaders might be confusing (largely mitigated by docs?) and deciding where to put each dependency might be confusing as well. 🤷♀️
will squash before merge
found issue: there should be a better way to report that a loader is invalid will be squashed before merge
will squash before merge
|
@cwyc Could you resolve the conflicts? |
|
Sorry I have not managed to review this early enough for this to make it into 2022.11. I have created a workaround for now #197029 |
in Nix (NixOS/nixpkgs#153275). Now the theme switcher will show the proper theme preview image
Motivation for this change
The gdk-pixbuf library can search for "modules" or "loaders" to extend its ability to load image formats. The modules available on a system are gathered and listed in a
loaders.cachefile, which gdk-pixbuf looks for in$GDK_PIXBUF_MODULE_FILE.Gdk-pixbuf recognizes only one loaders.cache file. This isn't a problem on other distributions, which call
gdk-pixbuf-query-loadersafter installation to update the systemwide loaders.cache that contains every installed loader.But nix can't do that, so 1) a program can't be packaged with loaders from multiple packages, and 2) if a program is packaged with a loader, the user can't extend it with other loaders in their environment.
We see the first issue with pretty much all GTK apps, which need loaders from librsvg as well as gdk-pixbuf. Our solution is to manually merge all of gdk-pixbuf's loaders.cache entries in to librsvg's, and use only the latter. But that doesn't support any other package providing loaders.
Things done
A better way could be for gdk-pixbuf to accept multiple loaders.cache. (see #42562 (review) )
First, module loading code in gdk-pixbuf is patched to read multiple paths from
$GDK_PIXBUF_MODULE_FILE, separated by a colon.Second,
wrapGappsHook, which sets$GDK_PIXBUF_MODULE_FILEfor most executables using gdk-pixbuf, is patched so that it appends to it rather than replaces it. This will let user-set loaders inservices.xserver.gdk-pixbuf.modulePackagesbe recognized.Third, the setup hook by which
gdk-pixbufincludes its own loaders is updated to take advantage of this feature. (see #102189 (comment) )Currently, packages include the hybrid-librsvg-gdk-pixbuf-loaders.cache either by setting
$GDK_PIXBUF_MODULE_FILEforwrapGappsHookto pick up, or by manually supplying it tomakeWrapper.Even though it's possible to supply librsvg and gdk-pixbuf separately, I've left librsvg as is for compatibility's sake.
And while this patches the
wrapGappsHookpackages to append rather than replace the environment variable, the manually-wrapped packages are unchanged.Warning: this triggers a lot of compilation.
Documentation hasn't been updated.
Tagging @jtojnar
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)nixos/doc/manual/md-to-db.shto update generated release notes