Hello NixOS Community!
Pardon the revival of an old thread, but long story short I went down a very long rabbit hole working on an issue that led me down to this thread while google dorking.
I’m posting here because I’m pretty sure I resolved the issue, and in case anyone else lands on this page while diagnosing similar problems, I hope my solution and diagnosis can provide you a fix.
Making Hyprland + GTK Play Nicely
Both the beauty and the pain of Linux, especially on build-it-yourself wms / compositors that don’t provide a complete “set” of pre-built stuff like hyprland is (not) knowing what you might be missing, or how some things prefer to communicate to each other along with their defaults.
I essentially was trying to get a custom icon theme to work system-wide, and the intention was to handle this through gtk, since a lot of components use that to pull settings and configs from. I found what I thought were the settings that were being defaulted to under ~/.config/gtk-{3,4}.0/settings.ini
. Changed those. No dice. Which was odd, because all the paths that gtk should be looking for the ini files were there and in the right places, according to other posts across the internet. Tried making and adding it in /etc/xdg/gtk-4.0/
. Still nothing.
I needed to do more digging.
I made gpt whip up this little script that helped me see what environment variables were set, what gtk’s defaults are in the system, what (if any) providers are…providing, icon-theme search paths (you can replace this w/ any setting you’re diagnosing), and the final result of the property currently being shown/active (again, you can change this to what you’re looking for)
nix-shell -p python3Packages.pygobject3 gtk4 --run '
python3 - << "PY"
import gi, os, sys
gi.require_version("Gtk", "4.0")
gi.require_version("Gdk", "4.0")
from gi.repository import Gtk, Gdk
# 1. Print Environment Vars related to GTK / XDG
print("=== Environment Variables Related to GTK / XDG ===")
for var in sorted(os.environ):
if any(pref in var for pref in ("GTK_", "XDG_", "GDK_", "GIO_", "DESKTOP_")):
print(f"{var}={os.environ[var]}")
print()
# 2. Grab the default Gtk.Settings and print all its properties
settings = Gtk.Settings.get_default()
if settings is None:
print("ERROR: Gtk.Settings.get_default() returned None")
sys.exit(1)
print("=== Gtk.Settings Properties (name = value) ===")
for prop in settings.list_properties():
name = prop.name
try:
val = settings.get_property(name)
except Exception:
val = "<unreadable>"
print(f" {name} = {val!r}")
print()
# 3. Show which provider types are in use (GioSettingsProvider, XSettingsProvider, etc.)
print("=== Gtk.Settings Providers (GObject type names) ===")
provider_list = getattr(settings, "_provider_list", None)
if provider_list:
for provider in provider_list:
print(" •", type(provider).__name__)
else:
print(" • (no _provider_list attribute – GTK is not using any provider!)")
print()
# 4. Show the actual icon‐theme search path GTK is using
icon_theme = Gtk.IconTheme.get_for_display(Gdk.Display.get_default())
print("=== IconTheme Search Path (directories GTK will scan) ===")
for p in icon_theme.get_search_path():
print(" •", p)
print()
# 5. Show the final ACTIVE icon‐theme‐name property:
print("==> Final ACTIVE icon‐theme‐name:")
print(settings.get_property("gtk-icon-theme-name"))
PY
'
Interestingly, I noticed something odd; the gtk defaults did not match what was in the ini file I had. Which, again, shouldn’t be happening. Plus, it was still picking up the original base icon theme, even though I explicitly set all kinds of envs and settings to tell it otherwise. It also, notably, had no providers listed, so I know there wasn’t anything accidentally interfering with any of my manual settings. However, it did kind of confuse me. If I had no providers, how come stuff displays?
Now, I’m new to NixOS (I fucking love it though btw), but it allegedly builds things in a way that’s dependency-safe, no? So, something (I’m suspecting hyprland) when built through nix must be pulling and activating some stuff, but not everything (and not enough to run some commands needed).
The Fix
Note I’m not using Home-manager or whatever, I’m doing everything in a plain configuration.nix file that I’m eventually going to turn into a flake. That being said, add these first:
services.gvfs.enable = true; # <- this gives the full feature set for thunar
...
programs.xfconf.enable = true;
programs.dconf.enable = true; # <- add this after environment.systemPackages, otherwise it won't be found
I’ve seem some mention dconf may be enabled by default if other things are enabled I guess? Idk do it anyway just to be safe (it never appeared for me personally until i enabled it).
Also add dconf-editor
pkg to test out if the changes it makes works or not.
I noticed when I ran dconf-editor
, it displayed the actual settings I found from the earlier code’s output! Whew! I was finally getting somewhere!
When that changed the settings across the board (including for thunar), I knew I’ve found the culprit.
Idk why, but even though I never specified any kind of gnome pkg in my nix config, changing the settings had to be managed under gsettings
, which was hard to do without any kind of gnome stuff (until I got dconf-editor). I suspect maybe it has something to do with what Hyprland ships with by default (or lack thereof) when a nix declaration builds it? Idk I haven’t gone through NixOS’s intricacies with a fine-toothed comb yet, that’s just my best guess.
Anyways, to make any changes you want persist from what you made from dconf-editor
or dconf, add this to your configuration.nix file:
programs.dconf.profiles.user.databases = [
{
settings."org/gnome/desktop/interface" = {
(place setting key/values here)
}
];
source
Et voila, Customize your defaults to your heart’s content.
This isn’t exclusive to Thunar, this fixes settings that are missing across any app using GTK