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
gtk/icons: (re)build icon theme caches #48116
Conversation
This is not an xdg thing, it is a gtk thing, so I think it should be in a separate module. I had thought that we would be able to make a shared cache, but it looks like we still have to do it per-theme, leading to the awkward dance with writing into the directory. That makes me think that we were wrong in saying that it's global state: it is actually per-theme state, so maybe we should actually be putting it in the individual theme packages. |
Also, doing it in the package will make icon themes installed with nix-env work too. |
Each icon theme has its cache. The difficult is that many packages may contribute with icons to the theme by installing some icons. For instance, on my current NixOS system, the following packages (among many others) have icons installed into the As another example, the The When the cache is built all of its icons has to be known. How to implement this? |
Ah, I hadn't understood that, thanks! In that case I agree that this is the right thing to do. I do think there's probably an issue with themes installed with nix-env (what happens if you have icons for the same theme spread across multiple XDG_DATA_DIRS anyway?), but arguably upstream should provide a better utility for that. |
I think that most themes have all icons installed by only one package. On my system there are 71 themes installed. Only 3 of them have icons installed from more than one package. If the main package of the theme provides a cache, presumably most of its icons will be available to applications without running a service. Only additional icons offered by other packages will not be available. Therefore I think that it is good that the main theme package installs a cache (although it does not completely fixes the situation for packages installed with The service solution presented here keeps the cache when there is only one package contributing with icons to the theme. Otherwise it rebuilds the cache taking all the icons into account. |
@michaelpj does this look ready to merge to you? Just want to make sure all potential issues have neen addressed here. |
I still think this should be in a different module. Otherwise I'm happy, although it would be good if the rationale discussed in the comment thread was recorded in the code too. |
Yeah maybe leave it in system-path.nix for now? I’m not sure how else to handle it though… We want it to work in every gtk based de. |
I think there should bea gtk module for this sort of stuff, like the xdg ones. |
@michaelpj I can migrate it to a new gtk module if you prefer. |
@michaelpj @matthewbauer I have written the new gtk module for setting the icon cache. (Why was @infinisil asked to review? Is he really the owner of 3 files in this PR? It does not seem so.) |
Awesome! Looks good to me. |
Lgtm, thanks! |
@matthewbauer Maybe you can merge #47690 too. It is related. |
options = { | ||
gtk.iconCache.enable = mkOption { | ||
type = types.bool; | ||
default = true; |
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.
Okay, so this broke the installer tests and while it would be trivial to just add gtk3
to the system closure, I think this should only default to true
if the user really has a graphical setup, eg. not on a headless server system.
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.
We could set it to true in xserver.nix
. I did something similar for the XDG modules, but I wasn't brave enough to make the default be false, because no doubt some people are running with weird systems but still want GTK icons.
Could we not just set it to false in the installer?
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.
Before this PR, in the system-path
module, there was not an explicit dependency on gtk3
, and the hicolor
icon theme cache was being built with
if [ -x $out/bin/gtk-update-icon-cache -a -f $out/share/icons/hicolor/index.theme ]; then
$out/bin/gtk-update-icon-cache $out/share/icons/hicolor
fi
That is, the cache was being built only if gtk-update-icon-cache
was available on the system.
Would it be reasonable to keep this approach in the new gtk
module? I am not sure.
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.
No, please don't go back to that, making the dependency explicit is the main reason I like this!
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.
Having this enabled by default also breaks NixOS on armv6l, because gtk eventually depends on valgrind, which doesn't build on armv6l.
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.
Probably the armv6 stuff is a separate issue which should be addressed in the appropriate place.
# The module solution presented here keeps the cache when there is | ||
# only one package contributing with icons to the theme. Otherwise it | ||
# rebuilds the cache taking into account the icons provided all | ||
# packages. |
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.
I think this whole comment block really belongs to the commit message (which should describe the reasons why you introduced that change) rather than here and I'd only keep the first and last paragraph here as a comment.
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.
I suppose this change would need a git amend or rebase. I do not know how to accomplish it once the PR has been committed.
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.
New PR.
Ok so this adds gtk3 to lots of places where it wasn't needed before. I think we can still use this new module but need to make it optional using the
For it to only do this when you already have gtk in your system. |
I really don't think we should do that - half the point of this is to make the gtk dep explicit. I think we should either disable it by default and enable it in various wms, or manually disable it when we don't want it. |
We have the |
The icon caches are needed by GTK applications (which are graphical applications) and may run in one of the GDK backends. Running GTK+ Applications mentions the following backends:
Which of these backends are supported in NixOS? Is there a module for each supported backend?
Is it plausible to disable it by default and enable it in module Those running with weird systems without xserver but still wanting GTK icons could enable it explicitly. |
It's a quick approximation to unblock unstable channels after #48116. This commit isn't ideal, as I suspect most wayland users won't have xserver.enable, so they will lose the icon cache in case they had gtk in system path (otherwise they didn't get cache anyway). I considered using environment.noXlibs, but the nixos tests installing headless systems do *not* get that option, so we would still be pulling gtk in many cases where it's clearly not desired. We need to design this more carefully.
Right, for now I pushed the approximation via Wayland probably works on NixOS. Quartz and win32 are irrelevant for NixOS; mir and broadway seem unlikely in this context. Config designPerhaps we need some profile or explicit option for most common "headless vs. desktop" code, but I'm afraid that needs more time to design and discuss, and perhaps it also needs nontrivial changes (possibly backwards incompatible). There's |
I did propose disabling the XDG modules by default (#45920), but I was worried about the breakage potential. |
Yes, I wouldn't do that by itself, as "desktop" users typically want these IMHO. I'm still not sure in what way exactly these configs should best be "triggered". ATM I suppose it might look like factoring out the common desktop code into one place (a profile or option) and have all display managers trigger that code by default. I'd expect these would be |
Motivation for this change
(Re)build icon theme caches of all shared icon themes by the
icons
xdg service.Up to now only the
hicolor
icon theme has its cache automatically built by thesystem-path
service. This PR generalizes it for all icon themes in the system path.See also #45058.
cc @michaelpj @jtojnar @vcunat
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)