NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.09k stars 14.08k forks source link

qt6ct and qt6Packages.qtstyleplugins-kvantum are not working together #239909

Closed thiagokokada closed 1 year ago

thiagokokada commented 1 year ago

Describe the bug

Setting QT_QPA_PLATFORMTHEME=qt5ct or QT_QPA_PLATFORMTHEME=qt6ct and QT_STYLE_OVERRIDE=kvantum is not working. This is what happens when I run the qt6ct application via command-line:

$ qt6ct
QApplication: invalid style override 'kvantum' passed, ignoring it.
    Available styles: qt6ct-style, Windows, Fusion
Configuration path: "/home/thiagoko/.config/qt6ct"
# ...

However doing the same and running qt5ct works as expected. I am assuming we are missing a wrap or something here.

Steps To Reproduce

Steps to reproduce the behavior:

  1. nix-shell -p qt6Packages.qtstyleplugin-kvantum qt6ct
  2. Run export QT_QPA_PLATFORMTHEME=qt6ct export QT_STYLE_OVERRIDE=kvantum
  3. Run qt6ct

Expected behavior

qt6ct should work correctly and you should see kvantum styles in the Style dropdown.

Screenshots

Ignore the The application is not configured correctly. This happens because of the QT_STYLE_OVERRIDE=kvantum, and while this is not recommended by qt6ct it is recommended by kvantum.

Additional context

I am using the qt module in Home-Manager, but in case of issues in the module I am happily to port any fixes to it.

Notify maintainers

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.3.4-zen1, NixOS, 23.11 (Tapir), 23.11.20230623.3ae20aa`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.15.1`
 - nixpkgs: `/nix/store/h26619k1aq8xj025905p5qqsxj8xdcmm-source`
Flakebi commented 1 year ago

I can reproduce an issue with inconsistent looking themes, but qt6ct works with kvantum for me. I have some dark theming in qt5 and qt6, but the style is inconsistent.

In addition to your settings, I also have this in .config/qt6ct/qt6ct.conf:

[Appearance]
style=kvantum
…

My .config/Kvantum/kvantum.config:

[General]
theme=KvArcDark

Config, that I have that is related to theming:

  environment.systemPackages = with pkgs; [
      arc-kde-theme
      libsForQt5.frameworkintegration
      kde-gtk-config
      kwayland-integration
      qt5.qtwayland
      libsForQt5.qtstyleplugin-kvantum
      qt6.qtwayland
      kvantumQt6
      qt6ct
      qtstyleplugin-kvantum-qt4
  ];

    environment.variables = {
      QT_STYLE_OVERRIDE = "kvantum";
      QT_QPA_PLATFORMTHEME = lib.mkForce "qt6ct";
  };

    qt = {
      enable = true;
      platformTheme = "qt5ct";
    };
Scrumplex commented 1 year ago

If you set QT_QPA_PLATFORMTHEME to qt6ct, Qt 5 apps will not be themed using either qt5ct or qt6ct. If you set it to qt5ct both Qt 5 and Qt 6 app should use qt5ct and qt6ct respectively.

You shouldn't need to add qt6ct to environment.systemPackages either as that's already done by qt.platformTheme = "qt5ct"

thiagokokada commented 1 year ago

Ok, so if I set:

# NixOS
qt = {
  enable = true;
  platformTheme = "qt5ct";
};

It works for both qt5ct and qt6ct, however:

# Home-Manager
qt = {
  enable = true;
  platformTheme = "qtct";
};

Only works in qt5ct, even if it basically does the same (export QT_QPA_PLATFORMTHEME=qt5ct). If you set both in NixOS and Home-Manager it also works.

So I assume the issue here is either that qt5ct only works when added to environment.systemPackages (but doesn't work with the Home-Manager equivalent, home.packages) or is that the NixOS module is adding extra packages that are missing in the Home-Manager module.

thiagokokada commented 1 year ago

So I assume the issue here is either that qt5ct only works when added to environment.systemPackages (but doesn't work with the Home-Manager equivalent, home.packages)...

This also explain why it also doesn't work with nix-shell -p qt6Packages.qtstyleplugin-kvantum qt6ct, because the issue seems to be at user profile level.

thiagokokada commented 1 year ago

I double checked the packages that the NixOS modules adds vs Home-Manager and it doesn't seem they're doing anything different (both add libsForQt5.qtstyleplugin-kvantum and qt6Packages.qtstyleplugin-kvantum when qt.platformTheme = "qt{,5}ct" is set). So I assume it is something that environment.systemPackages is doing that makes it work.

I am also curious why home.packages works in qt5ct and not in qt6ct. Maybe whatever qt5ct is doing could be backported to qt6ct so this could be fixed for every use case.

Scrumplex commented 1 year ago

Maybe this? https://github.com/NixOS/nixpkgs/blob/094681cd1e14261333f503bcbfacbb62362b686a/nixos/modules/config/qt.nix#L111-L116

It's very important that both Qt 5 and Qt 6 plugin paths are linked

thiagokokada commented 1 year ago

Maybe this?

https://github.com/NixOS/nixpkgs/blob/094681cd1e14261333f503bcbfacbb62362b686a/nixos/modules/config/qt.nix#L111-L116

It's very important that both Qt 5 and Qt 6 plugin paths are linked

Interesting that the Qt modules in Home-Manager does neither of them, and qt5ct still works.

But I will try this later.

thiagokokada commented 1 year ago

Maybe this?

https://github.com/NixOS/nixpkgs/blob/094681cd1e14261333f503bcbfacbb62362b686a/nixos/modules/config/qt.nix#L111-L116

It's very important that both Qt 5 and Qt 6 plugin paths are linked

Just setting those 2 environment variables in my config did the trick. So I think this is actually an bug with Home-Manager module where we need to setup those 2 variables too.

thiagokokada commented 1 year ago

Going to close this issue since I opened a PR in Home-Manager to fix this issue: https://github.com/nix-community/home-manager/pull/4579

diniamo commented 2 weeks ago

I have this exact issue, with the only difference being that it happens even with both the NixOS and the HM module enabled, I have also tried enabling either one. My configuration has been working for a while, and I didn't change anything, meaning it broke because of updating nixpkgs. Any ideas?

eljamm commented 1 week ago

This happened to me lately as well. Bisecting nixpkgs, I traced the issue back to qt6: 6.7.3 -> 6.8.0 · NixOS/nixpkgs@d4f7b84

diniamo commented 1 week ago

@K900 any idea what's going on?

K900 commented 1 week ago

Fixed in staging-next, please don't necropost.

Scrumplex commented 1 week ago

@diniamo @eljamm see #350514

diniamo commented 1 week ago

I couldn't find that issue when I last looked.