gtk3: fall back to packaged schemas for internal settings#507455
Open
ilkecan wants to merge 3 commits into
Open
gtk3: fall back to packaged schemas for internal settings#507455ilkecan wants to merge 3 commits into
ilkecan wants to merge 3 commits into
Conversation
Some Qt applications load GTK 3 through Qt's GTK platform theme and crash when GTK's own schemas are not visible through XDG_DATA_DIRS. This happens most visibly in the file chooser path when apps are wrapped with wrapQtAppsHook but not wrapGAppsHook3. Look up the normal default schema source first so environment-based overrides keep working, then fall back to GTK's own packaged schema directory for FileChooser, ColorChooser, and EmojiChooser. Co-authored-by: Jan Tojnar <jtojnar@gmail.com>
The existing generator always prefers the hardcoded schema directory and only uses the default schema source as a parent. Some consumers, such as `gtk3`, need the opposite precedence so environment-driven overrides continue to work. Add an opt-in `preferDefaultSchemaSource` mode that first looks up the schema in the default source and only falls back to the hardcoded directory when it is missing there. Keep the current hardcoded-first behavior as the default and cover the new mode with a fixture test.
Use `makeHardcodeGsettingsPatch` with the new default-first lookup mode and fold patch regeneration into `updateScript`. The generated patch currently covers the full GTK source tree, so the checked-in patch now includes the demo and example schema callsites again in addition to the library callsites that motivated the original fix. Co-authored-by: Jan Tojnar <jtojnar@gmail.com>
13 tasks
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
13 tasks
Member
|
👍 This fixes the same problem for KMyMoney, too. See #509718 (comment) |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
follow up from: #271037
Summary
Some Qt applications in nixpkgs crash when Qt loads GTK integration and GTK tries to instantiate its own GSettings schemas, most visibly in the GTK file chooser path.
Typical failures look like:
Settings schema 'org.gtk.Settings.FileChooser' is not installedNo GSettings schemas are installed on the systemThe root cause is that GTK 3 library code directly constructs
GSettingsobjects for its own schemas, while those schemas live in package-specific paths in nixpkgs instead of a global location like/usr/share.wrapGAppsHook3often masks the issue by extendingXDG_DATA_DIRS, but Qt applications wrapped only withwrapQtAppsHookcan still hit the crash depending on the runtime environment.Solution
Patch GTK 3 itself so that when GTK asks for one of its own internal schemas, it:
That parent relationship is intentional. It does not change the default-first lookup order, because the target schema is still looked up in the fallback source with
recursive = FALSE, but it allows fallback-loaded schemas to resolve references through the default source1.This covers the crash-relevant GTK library schemas:
org.gtk.Settings.FileChooserorg.gtk.Settings.ColorChooserorg.gtk.Settings.EmojiChooserThe fix is deliberately scoped to GTK's own internal schemas rather than arbitrary third-party schemas.
Default-first approach
A hardcoded-first patch would make GTK's packaged schema win even when the schema is already available through the normal default source, and it could weaken environment-driven override behavior. @jtojnar called this out on the earlier draft PR and suggested checking the default source first, then falling back to the hardcoded path only when needed. This PR follows that approach.
Automation
The PR also extends
makeHardcodeGsettingsPatchwith an opt-in default-first mode and uses it forgtk3so future GTK updates can regenerate the patch without losing these semantics.The generated patch currently also includes GTK demo and example callsites because the helper runs over the GTK source tree. Those hunks are not needed for the original Qt crash, but they are harmless and kept to avoid adding extra helper complexity in this change.
Testing
I tested 3 previously crashing applications against the patched
gtk3:brewtarget2 no longer crashed when run with a deliberately strippedXDG_DATA_DIRS, while the unpatched nixpkgs build still didscribus3 also stopped crashing on startup, while the unpatched nixpkgs (nixos-25.11) build still crashedovitodoesn't crash when launching filechooser with these changes. confirmed the crash on master.You can download the pre-built
ovitofrom this PR to test:Follow-up cleanup
After this lands, we should audit recent wrapGAppsHook3 additions on Qt packages and remove the ones that were only added to work around GTK's internal schema lookup failures. This should be done selectively, since some packages may still need wrapGAppsHook3 for unrelated runtime data.
Relevant issues & PRs (not comprehensive)
Things done
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.Footnotes
https://docs.gtk.org/gio/ctor.SettingsSchemaSource.new_from_directory.html#description ↩
tested before https://github.com/NixOS/nixpkgs/commit/e7b6af9d4f189e1fc58eec32c01529dc6a05fe43 landed ↩
tested before https://github.com/NixOS/nixpkgs/commit/23b5ac11e2181d087c884c6426591d7fdeb0962b ↩