1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-18 19:51:17 +00:00

nixos/gnome: enable platform integration for Qt

Qt links against GTK to be able to use native GTK file chooser
in GTK-oriented DEs. However, GTK expects a specific environment,
which means the application needs to be wrapped to prevent crashes
when file chooser is opened in some environments.

This patch bypasses the need for wrapping Qt applications with GTK-related
environment since the file chooser dialogue will now come from a separate
process (instantiated by the XDG desktop portal via D-Bus).

In the future, we could remove the GTK dependency from Qt to fix the crashes
on non-{GNOME,Pantheon} environments. Then, users would be able to choose
between non-native Qt dialogue or native one facilitated by XDG portals
(e.g. through setting `QT_QPA_PLATFORMTHEME` to either `qgnomeplatform`,
or `xdgdesktopportal`).

One disadvantage is adding a Qt dependency to GNOME, even for people
who might not use any Qt apps. But they can easily just add `qt5.enable = false;`
to their NixOS configuration.

The configuration is also presumably less battle tested than plain Qt
with its first-party GTK integration. But it is backed by Fedora
and used by Manjaro GNOME so it cannot be that bad.

Lastly, I worry about ABI compatibility of the platform modules
with apps installed from different Nixpkgs revision.
This commit is contained in:
Jan Tojnar 2021-08-29 02:28:38 +02:00
parent ce77cbef67
commit 47afdc4627
3 changed files with 18 additions and 0 deletions

View file

@ -1088,6 +1088,15 @@ Superuser created successfully.
but instead use more of the YAML-specific syntax.
</para>
</listitem>
<listitem>
<para>
GNOME desktop environment now enables
<literal>QGnomePlatform</literal> as the Qt platform theme,
which should avoid crashes when opening file chooser dialogs
in Qt apps by using XDG desktop portal. Additionally, it will
make the apps fit better visually.
</para>
</listitem>
</itemizedlist>
</section>
</section>

View file

@ -311,3 +311,5 @@ To be able to access the web UI this port needs to be opened in the firewall.
- Nginx will use the value of `sslTrustedCertificate` if provided for a virtual host, even if `enableACME` is set. This is useful for providers not using the same certificate to sign OCSP responses and server certificates.
- `lib.formats.yaml`'s `generate` will not generate JSON anymore, but instead use more of the YAML-specific syntax.
- GNOME desktop environment now enables `QGnomePlatform` as the Qt platform theme, which should avoid crashes when opening file chooser dialogs in Qt apps by using XDG desktop portal. Additionally, it will make the apps fit better visually.

View file

@ -372,6 +372,13 @@ in
xdg.portal.enable = true;
xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
# Harmonize Qt5 application style and also make them use the portal for file chooser dialog.
qt5 = {
enable = mkDefault true;
platformTheme = mkDefault "gnome";
style = mkDefault "adwaita";
};
networking.networkmanager.enable = mkDefault true;
services.xserver.updateDbusEnvironment = true;