How to fix qt themes in nixos?

I’m trying out nixos in a virtual machine (gnome desktop) to test it outandI’ve come to love it, except for the fact that qt themes don’t really work,pic related https://files.catbox.moe/gj7vcw.jpg. I tried installing qt5ct tosee if that fixes the issue but in the styles optionsit doesn’t give me anoption to select gtk. I thought of using kvantum to fixthe problem but it’snot in the nixos repo. Does anyone have any idea on how Icould fix this?Myconfiguration.nix is here https://files.catbox.moe/1l3gmv.nix

This page in the ArchLinux wiki may be helpful, as most of the strategies described apply to NixOS too.

Kvantum is in nixpkgs: NixOS Search - Loading...

You can check my config here configurations/dracula.nix at 0f41d4a04c6dce1ceac6ab4e4aeaf588f68be844 · addy419/configurations · GitHub If you face issues with theme consistency even after installing Kvantum, I highly suggest using lxqt-config (also in the dots above)

To get Qt themes working on Nixos you need to install the theme engine you want to use, and then use the QT_STYLE_OVERRIDE environment variable to select it.

For example, I’m using the following, which works for VLC:

/etc/nixos/confuration.nix:

   ...
      environment.systemPackages = with pkgs; [
        # The following is a Qt theme engine, which can be configured with kvantummanager
        libsForQt5.qtstyleplugin-kvantum
     ];

     environment.variables = {
        # This will become a global environment variable
       "QT_STYLE_OVERRIDE"="kvantum";
     };

Even after a nixos-rebuild switch the settings won’t take effect. The simplest way is to simply log back in, that way /etc/profile is sourced properly.

3 Likes

This is no longer working as of Nixos 22,
somehow the QT styles are now hardcoded into the module:

building Nix...
building the system configuration...
error: The option `environment.variables.QT_QPA_PLATFORMTHEME' has conflicting definition values:
       - In `/etc/nixos/configuration.nix': "qt5ct"
       - In `/nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/config/qt5.nix': "gnome"
(use '--show-trace' to show detailed location information)
  environment.variables = {
    QT_QPA_PLATFORMTHEME = "qt5ct";
  };

You can override this using

  environment.variables = lib.mkForce {
    QT_STYLE_OVERRIDE = "{theme}";
  };

I think qt.style needs to be modified to include options for qt5ct and kvantum if they’re installed.

1 Like

hello quasi a god :grinning_face_with_smiling_eyes:
This also doesn’t seem to work for me.
How would I modify qt.style?

What theme exactly are you trying to use? Are you using something like qt5ct or Kvantum to set your theme?

My config seems pretty straight forward but each time I open kvantummanager the kvantum (default) is selected and I can’t seems to change to my installed theme.

qt.enable = true;
qt.platformTheme = "qtct";
qt.style.name = "kvantum";

home.packages = with pkgs; [

  (catppuccin-kvantum.override {
    accent = "Mauve";
    variant = "Mocha";
  })
];

xdg.configFile."Kvantum/kvantum.kvconfig".source = (pkgs.formats.ini {}).generate "kvantum.kvconfig" {
  General.Theme = "Catppuccin-Mocha-Mauve";
};
1 Like

If you remove the xdg.configFile and open Kvantum, do you see the catppuccin theme in the list?

1 Like

I feel very dumb mentioning this but apparently “Theme” needed to be “theme”. Of course kvantummanager couldn’t change the theme because its config was read-only since it was in the nix store.

1 Like

Haha it happens. For config files like that, I usually set it up in the GUI then add it to my Nix config by just pasting the text in.

1 Like