Nixpkgs: GTK themes and icons can be selected, but not loading.

Created on 28 Feb 2016  ·  19Comments  ·  Source: NixOS/nixpkgs

Basic info

  • System: 16.03pre77568.40c586b (Emu)
  • Nix version: nix-env (Nix) 1.11.2
  • Nixpkgs version: "16.03pre77568.40c586b"
  • XFCE version: Xfce 4.12.1

    Describe your issue here

Imagine some casual user. Person who likes to have full-fledged desktop environment, but no too polluted, like XFCE is. He also cares a lot about appearance of his desktop, so he got an idea to find some icon and GTK themes to make his UI look a bit better. But after installing arc-gtk-theme and elementary-icon-theme nothing went like he'd expected to.

Expected result

When user runs xfce4-appearance settings and chooses "Style" tab, changing to any style results in reloading GTK style in every running app (if app doesn't support DBus messages or is run as root, it might be restarted to apply this), same thing with "Icons".

Actual result

After choosing 3rd party theme, like previously mentioned Arc, it keeps selected, but falls back to default Raleigh one, without any message about what the hell happened right now. But after rebooting, theme is applied correctly (only if installed as systemPackages). Logging off and on doesn't help.
The icon theme doesn't apply even after reboot, and xfce4-appearance-settings shows red triangle on selected icon theme, with information about missing icon cache, which can't be regenerated manually, because /run/current-system/sw/ is read-only.

Steps to reproduce

  • Install NixOS with standard, automatically generated configuration, just add:
services.xserver.desktopManager.xterm.enable = false;
services.xserver.desktopManager.xfce.enable = true;
services.xserver.displayManager.lightdm.enable = true;
  • As user, run:
# adding to systemPackages in configuration.nix was tested too with same effect
nix-env -i arc-gtk-theme elementary-icon-theme
xfce4-appearance-settings
  • Be lost and try to figure how it can be fixed. I think icon themes should have post-install hook to run gtk-update-icon-cache, but I'm not sure what's happening with GTK themes.
bug xfce

Most helpful comment

tl;dr: add the following to your nixos config, logout+login

# Use librsvg's gdk-pixbuf loader cache file as it enables gdk-pixbuf to load SVG files (important for icons)
environment.sessionVariables = {
  GDK_PIXBUF_MODULE_FILE = "$(echo ${pkgs.librsvg.out}/lib/gdk-pixbuf-2.0/*/loaders.cache)";
};
  1. I tried using elementary-icon-theme and ran into the icons being blank
  2. Next I tried numix-icon-theme and had the same issue - blank icons
  3. Then I tried arc-icon-theme and it worked!
  4. scratched my head and figured out elementary-icon-theme and numix-icon-theme are SVG whereas arc-icon-theme uses PNGs

    • 💡 ah-hah that's the difference

  5. little bit of research told me that gdk-pixbuf is used to load icons in GTK

    • researched svg support for gdk-pixbuf

    • found out that svg support is provided by librsvg

  6. inspected the librsvg nix package and noticed a line about: The loaders.cache can be used by settingGDK_PIXBUF_MODULE_FILEto point to this file in a wrapper.
  7. searched issues for GDK_PIXBUF_MODULE_FILE and found https://github.com/NixOS/nixpkgs/issues/16268#issuecomment-226964988
  8. made changes and icons worked 👍

Hope this helps!


BTW I used the xfce settings to change icon sets - not lxappearance

All 19 comments

/cc @lethalman. I know too little about gtk* themes.

Icon themes

It depends on the theme. I use the tango theme installed via nix-env and it works, because the theme did generate its icon-theme.cache when building itself. I'd think we should fix the individual themes to do so. (It means introducing extra build-time-only dependencies, but I personally don't think that's a problem, especially if we allow building the stuff on Hydra.)

There's this problem of not regenerating on installation into an user/system env, but IMO it's better done individually except for themes that are meant to compose (probably just the "hicolor" theme).

Can we just make single icon-theme template for all of them, which will take care of updating icon cache and so on?

And this one (https://github.com/NixOS/nixpkgs/issues/5053) suggests a workaround but I haven't tested it.

I do experience this as well. Chromium gets styled, nautilus doesn't; for example.

I wonder if removing the cache altogether from system, makes everything work ok. That is, even without the "cache", icons should work, right? I have to try...

What's going on with that?

I am also affected by this problem.
Wouldn't just adding

 postInstall = '''${gtk.dev}/bin/gtk-update-icon-cache' "$out/share/icons/Elementary" '';

be enough to make at least the elementary-icon-theme package work?
(I unfortunately can't test it right now, as I did set up NixOS just one hour ago and don't know how to change packages locally yet.)

I think that something similar is happening to me with

$ nixos-version
17.03.1395.9b948ea439 (Gorilla)

$ nix-env --version
nix-env (Nix) 1.11.11

I use lxappearance to select the theme. To have it show widget and icon themes installed with nix-env I had to symlink ~/.nix-profile/share/icons and ~/.nix-profile/share/themes to ~/.icons and ~/.themes respectively. However, the changes are not saved.

Normally lxappearance saves its settings to ~/.gtkrc-2.0, but nothing happens for me (even when I manually create that file and make it world-writeable).

EDIT: icons does not need to be symlinked, but themes does.

Has this been solved or no?
I installed some numix themes and they didn't work.
GTK theme a no show in lxappearance, icon theme showed up but does nothing.

@Nobabs27 you may have to symlink ~/.nix-profile/share/themes to ~/.themes to have them shown in lxappearance but they won't be applied anyway.

So how do I get them applied?

Also, there is no ~/.nix-profile/share/themes for me.

@Nobabs27 maybe you need to install a theme as your user with nix-env.

Also, if you edit manually you ~/.gtkrc-2.0 some applications will be able to pick up the theming.

Installing via nix-env no change.
Created a .gtkrc-2.0 with this line: gtk-theme-name="Arc-Dark"
No change still...
Although lxappearance works fine in XFCE, it does not work in i3wm.

tl;dr: add the following to your nixos config, logout+login

# Use librsvg's gdk-pixbuf loader cache file as it enables gdk-pixbuf to load SVG files (important for icons)
environment.sessionVariables = {
  GDK_PIXBUF_MODULE_FILE = "$(echo ${pkgs.librsvg.out}/lib/gdk-pixbuf-2.0/*/loaders.cache)";
};
  1. I tried using elementary-icon-theme and ran into the icons being blank
  2. Next I tried numix-icon-theme and had the same issue - blank icons
  3. Then I tried arc-icon-theme and it worked!
  4. scratched my head and figured out elementary-icon-theme and numix-icon-theme are SVG whereas arc-icon-theme uses PNGs

    • 💡 ah-hah that's the difference

  5. little bit of research told me that gdk-pixbuf is used to load icons in GTK

    • researched svg support for gdk-pixbuf

    • found out that svg support is provided by librsvg

  6. inspected the librsvg nix package and noticed a line about: The loaders.cache can be used by settingGDK_PIXBUF_MODULE_FILEto point to this file in a wrapper.
  7. searched issues for GDK_PIXBUF_MODULE_FILE and found https://github.com/NixOS/nixpkgs/issues/16268#issuecomment-226964988
  8. made changes and icons worked 👍

Hope this helps!


BTW I used the xfce settings to change icon sets - not lxappearance

This should be largely solved by now except for icon theme cache: to fix the missing cache, there should be a an additional step to generate it during the build.

As I just noticed during the test drive of NixOS 17.09 after about two years, the problem still exist.

Every time I choose icon theme added to the user environment (via nix-env -i) or system (via environment.systemPackages) it shows previously selected theme without any changes.

For GTK2/3 themes, when I try to switch on any of these, I'm getting something like the default GTK (Raleigh) theme (used on Windows platform, for example) with colors set from newly selected one, but somewhat ommiting all the CSS it has.

Logging off and on does not resolve this, sadly.

I don't want to be rude or offending, but I want to ask – why such simple problem can't be fixed? I see there's a massive work put into the development of NixOS and Nixpkgs, but such little bug still resist, and many new or less-knowledgeable users can be easily took off.

Of course majority of developers here are using i3/dwm/something-wm and Emacs running constantly and rarely seeing ~the light of sun~ any other GUI applications. But there are also "desktop" users who want their windows and icons look as they used to be on other Linux distributions. Is that so hard?

I don't want to be rude or offending, but I want to ask – why such simple problem can't be fixed?

Contributions are welcome.

Is that so hard?

Trivial but menial; see: https://github.com/NixOS/nixpkgs/pull/35466/files

Was this page helpful?
0 / 5 - 0 ratings