Doom Emacs GUI segfault on NixOS 25.05 with GLib GSettings error; gsettings list-schemas shows none

Doom Emacs GUI segfault on NixOS 25.05 with GLib GSettings error; gsettings list-schemas shows none

Summary

  • Doom Emacs GUI segfaults at startup with GLib/GSettings critical error.
  • emacs -Q (GUI) works; emacs -nw (terminal) works; only Doom GUI crashes.
  • In my shell, gsettings list-schemas initially prints “No schemas installed”.
  • If I craft XDG_DATA_DIRS from store schema roots, gsettings lists many schemas, but Doom GUI still segfaults.

System

  • Timestamp / kernel: 2025-10-25T03:32:26-03:00Linux mantis 6.16.12 #1-NixOS x86_64
  • NixOS: 25.05.811621.c8aa8cc00a5c (Warbler)
  • Nix: nix (Nix) 2.28.5
  • Desktop: KDE Plasma 6.3.6; Qt: 6.9.2
  • Emacs: GNU Emacs 30.0.92
    Batch probe: build: x86_64-pc-linux-gnu, window-system: nil
    (Unsure if my GUI build is GTK3 or PGTK; it’s from /nix/store/...-emacs-30.0.92/bin/emacs.)
  • GLib/GSettings tools in PATH: gsettings: N/A, glib-compile-schemas: N/A
    (There are glib-compile-schemas binaries in the store dev outputs.)

Nix channels / profiles (relevant)

  • Channel: nixpkgs https://nixos.org/channels/nixpkgs-unstable
  • nix profile list (selected):
    • glib/nix/store/ji3yqx69...-glib-2.84.4-bin
    • gsettings-desktop-schemas/nix/store/03iq7iqv9...-gsettings-desktop-schemas-48.0
    • home-manager-path present
  • Registry: includes emacs-overlay, home-manager, nixpkgs-unstable, etc. (full list available)

Symptoms

Launching Doom Emacs GUI:


$ emacs --debug-init
Loading ~/.emacs.d/lisp/doom.el ...

* ... ~/.config/doom/init.el t

(process:XXXXX): GLib-GIO-CRITICAL **: g_settings_schema_source_lookup: assertion 'source != NULL' failed
Fatal error 11: Segmentation fault
Backtrace:
... /nix/store/...-emacs-30.0.92/bin/emacs() ...
... glibc-2.40-36/lib/libc.so.6 ...
Segmentation fault (core dumped)

What works:

  • emacs -Q (GUI) starts fine.
  • emacs -nw (Doom in terminal) starts fine.

What fails:

  • emacs (Doom GUI) segfaults early in init.

GSettings state

Baseline:


$ gsettings list-schemas | head
No schemas installed

Tried pointing to various gschemas.compiled from FHS envs (Steam/AppImage) — sometimes -Q starts, but Doom still crashes.

I then collected non-FHS schema roots:


$ find /nix/store -type d -path '*/share/gsettings-schemas/*' | head
/nix/store/b3d6...-gtk4-4.16.12/share/gsettings-schemas/gtk4-4.16.12
/nix/store/nz0b...-ibus-1.5.30/share/gsettings-schemas/ibus-1.5.30
/nix/store/nil2...-gnome-settings-daemon-47.2/share/gsettings-schemas/gnome-settings-daemon-47.2
...

Built XDG_DATA_DIRS from those /share roots (+ gsettings-desktop-schemas-48.0/share):


$ XDG_DATA_DIRS="<many /nix/store/.../share:>:$XDG_DATA_DIRS" gsettings list-schemas | head
org.freedesktop.pulseaudio.module-groups
org.gnome.desktop.a11y
org.gnome.desktop.interface
... (many)

Yet:


$ XDG_DATA_DIRS="..." emacs --debug-init
... still segfaults with the same GLib-GIO-CRITICAL and backtrace

I also attempted a user-local union of schema XMLs in ~/.local/share/glib-2.0/schemas and compiling gschemas.compiled, but I initially lacked a reliable glib-compile-schemas in PATH and didn’t complete a clean compile.


What changed recently

  • Running Plasma 6.3.6 on NixOS 25.05; I keep my system and HM updated.
  • I have gsettings-desktop-schemas-48.0 in my user profile via nix profile.
  • XDG_DATA_DIRS is large with many KDE/Qt paths; no glib-2.0/schemas on it by default.

Repro steps

  1. emacs -Qworks (GUI).
  2. emacs -nwworks (Doom in terminal).
  3. emacs (Doom GUI) → GLib-GIO-CRITICAL then segfault.
  4. gsettings list-schemasNo schemas installed (baseline shell).
  5. Export XDG_DATA_DIRS to include /nix/store/*/share/gsettings-schemas/*/glib-2.0/schemas parent dirs (plus gsettings-desktop-schemas-48.0/share) → gsettings lists schemas, but emacs (Doom GUI) still segfaults.

Hypothesis

Emacs GUI build (GTK/PGTK) isn’t wrapped with the expected gapps environment, so GLib lacks a default GSettings schema source. Doom likely touches GSettings early (theme or interface), triggering the crash. -Q avoids the code path; -nw avoids GTK entirely.


Questions for NixOS folks

  1. Which Emacs package/derivation should I use to ensure a proper gapps-wrapped GTK/PGTK Emacs on NixOS 25.05 (Warbler)?

    • e.g., should I switch to a specific pkgs.emacs30* variant or emacsPgtk from emacs-overlay, or use a Nix-provided wrapper?
  2. Is there a recommended way to make GSettings schemas discoverable system-wide (or per-user) without manual XDG_DATA_DIRS surgery?

    • Via environment.systemPackages + wrapGAppsHook, or programs.emacs module?
    • Any home-manager options to set XDG_DATA_DIRS/GSETTINGS_SCHEMA_DIR to the Nix “relocated” paths?
  3. If the root cause is Doom calling into GSettings at init, is there a known Doom-side workaround (env vars or disabling auto GTK/gnome integration) that avoids the crash?

Thanks in advance! Happy to test any wrapper or configuration patches. :nerd_face: