Guide to installing qt theme

Hello everyone, I can’t get the QT5 theme to work on Wayland. I’ve tried all the methods from the NixOS options, but they’re not working; the session variable just won’t apply.

I tried the following:

`qt = {
enable = true;
style = {
package = utterly-nord-plasma;
name = “Utterly Nord Solid”;
};
platformTheme = “qt5ct”; // I tried all other variants too.
};

environment.sessionVariables or environment.variables = {
QT_QPA_PLATFORM = “wayland”; // I tried all other variants too.
QT_QPA_PLATFORMTHEME = “qt5ct”; // I tried all other variants too.
};

environment.variables = {
“QT_STYLE_OVERRIDE” = “kvantum”; // I tried all other variants too.
QT_QPA_PLATFORMTHEME = “qt5ct”; // I tried all other variants too.
};

environment.variables = lib.mkForce {
QT_STYLE_OVERRIDE = “{mytheme}”;
};`

Additionally, if I export the variables directly in the terminal, it works. However, I can’t figure out how to make Hyprland’s share-picker use my theme, if I solve the problem, because it’s not working.

Thanks.

1 Like

Hey fellow Nix enthusiasts! :star2:

If you are venturing into the beautiful world of Nix and want to spruce up your Qt applications with a theme, here is a simple guide to get you started:

:wrench: System Configuration :wrench:

environment.systemPackages = with pkgs;
  [
    libsForQt5.qtstyleplugin-kvantum
    libsForQt5.qt5ct
];
nixpkgs.config.qt5 = {
  enable = true;
  platformTheme = "qt5ct"; 
    style = {
      package = pkgs.utterly-nord-plasma;
      name = "Utterly Nord Plasma";
    };
};

environment.variables.QT_QPA_PLATFORMTHEME = "qt5ct";

This snippet ensures your system knows about the qt6ct or qt5ct or Kvantum platform theme and qt6ct or qt5ct or Kvantum, a tool to apply stunning themes to Qt applications.

:house: Home Manager Configuration :house:

In your home.nix, you might want to fetch a fresh theme from the unstable channel and get access to theme directly :

  home-manager.users.varmisa = { pkgs, ... }: let
    unstablePkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz") {
      config = config.nixpkgs.config;
    };
  in {
    home.packages = with pkgs; [unstablePkgs.utterly-nord-plasma];
    xdg.configFile = {
      "Kvantum/Utterly-Nord-Solid-Plasma/Utterly-Nord-Solid/Utterly-Nord-Solid.kvconfig".source = "${unstablePkgs.utterly-nord-plasma}/share/Kvantum/Utterly-Nord-Solid/Utterly-Nord-Solid.kvconfig";
      "Kvantum/Utterly-Nord-Solid-Plasma/Utterly-Nord-Solid/Utterly-Nord-Solid.svg".source = "${unstablePkgs.utterly-nord-plasma}/share/Kvantum/Utterly-Nord-Solid/Utterly-Nord-Solid.svg";
      "Kvantum/Utterly-Nord-Solid-Plasma/Utterly-Nord-Solid/Nord.patchconfig".source = "${unstablePkgs.utterly-nord-plasma}/share/Kvantum/Utterly-Nord-Solid/Nord.patchconfig";
      "Kvantum/kvantum.kvconfig".text = "[General]\ntheme=Utterly-Nord-Solid";
    };

:eye: What’s happening here? :eye:

We’re telling our home environment to use a cool theme called ‘Utterly Nord Plasma’. By pointing to the unstable channel, we get the latest goodies. We also directly tell our system where to find the theme’s configuration files.

:file_folder: Finding Theme Files :file_folder:

Not sure where your theme’s files are? Run this magic spell in your terminal :

nix-store -q --requisites /nix/store/*-package-name*

Replace package-name with the name of your theme package. This command will reveal all the paths related to your theme in the Nix store.

Hope this helps! Happy theming! :sparkles:

P.S. Quick note, friends! This guide assumes that you’re using a setup where Home Manager is integrated as part of your Nix system configuration. If you’re running Home Manager standalone, the steps will differ slightly. This setup is great for a cohesive environment where system and user configurations are harmoniously blended. :handshake: Happy configuring! :hammer_and_wrench::sparkles:

3 Likes

Hi, thanks a lot for your post, it was very helpful to get it working on my side!

A couple things: the system configuration section you posted is actually a mix of HM and NixOS.
And I’ve got it down to something a bit simpler :slight_smile:

All of the following is in my HM config:

qt = {
  enable = true;

  platformTheme = "qtct";

  style.name = "kvantum";
};

xdg.configFile = {
  "Kvantum/kvantum.kvconfig".text = ''
    [General]
    theme=GraphiteNordDark
  '';

  "Kvantum/GraphiteNord".source = "${pkgs.graphite-kde-theme}/share/Kvantum/GraphiteNord";
};

I prefer not overriding qt.style.package so HM provides all the kvantum libs for me (there’s a couple you’re missing for Qt6, see here).

The quick way to find the theme name and path I do is open a shell with the theme package so it’s in your store. Then do ls /nix/store/*-${pkg}*.
You should see a share folder and in there the themes. The theme name is just the name of the .kvconfig file.

3 Likes

Hello, good to hear, now my config looks different, it’s modified, and I can’t move this thing to Home-Manager, I don’t know how the qtct option works for you, when it’s not in NixOS, there’s qt5ct instead.

My properly config now:

System and Home-Manager config:


  environment.sessionVariables = {
    XDG_CURRENT_DESKTOP = "Hyprland";
    XDG_SESSION_DESKTOP = "Hyprland";
    XDG_SESSION_TYPE = "wayland";
    GDK_BACKEND = "wayland";
    GTK_USE_PORTAL = "1";
    QT_QPA_PLATFORMTHEME = "qt5ct";
    QT_QPA_PLATFORM = "wayland";
    QT_WAYLAND_DISABLE_WINDOWDECORATION = "1";
    QT_AUTO_SCREEN_SCALE_FACTOR = "1";
    MOZ_ENABLE_WAYLAND = "1";
  };
  users.users.varmisa = {
    isNormalUser = true;
    description = "Varmisanth";
    extraGroups = [ "networkmanager" "wheel" "audio" ];
    packages = with pkgs; [
      unstable.telegram-desktop
      gnome.nautilus
      gparted
      (callPackage /etc/nixos/gui/terminals/rio/default.nix { })
      libsForQt5.qtstyleplugin-kvantum
      libsForQt5.lightly
      unstable.qt6Packages.qt6ct
      qt6.qtwayland
      qt5.qtwayland
      unstable.wl-screenrec
      appimage-run
      hyprpaper
      xdg-utils
      procps
      slurp
      grim
      imv
      wl-clipboard
      cliphist
      nix-prefetch-github
      git
    ];
  };
 qt = {
    enable = true;
    platformTheme = "qt5ct";
    style = {
      package = pkgs.catppuccin-kvantum;
      name = "kvantum";
    };
  };

  home-manager.users.varmisa = { pkgs, ... }:
    let
      unstablePkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz") {
        config = config.nixpkgs.config;
      };
    in
    {
      home.packages = with pkgs; [
        (unstablePkgs.catppuccin-kvantum.override {
          accent = "Blue";
          variant = "Macchiato";
        })
      ];
      xdg.configFile = {
        "Kvantum/Catppuccin-Macchiato-Blue/Catppuccin-Macchiato-Blue/Catppuccin-Macchiato-Blue.kvconfig".source = "${unstablePkgs.catppuccin-kvantum}/share/Kvantum/Catppuccin-Macchiato-Blue/Cattpuccin-Macchiato-Blue.kvconfig";
        "Kvantum/Catppuccin-Macchiato-Blue/Catppuccin-Macchiato-Blue/Catppuccin-Macchiato-Blue.svg".source = "${unstablePkgs.catppuccin-kvantum}/share/Kvantum/Catppuccin-Macchiato-Blue/Cattpuccin-Macchiato-Blue.svg";
      };
      gtk = {
        enable = true;
        theme = {
          name = "Tokyonight-Dark-BL";
          package = pkgs.tokyo-night-gtk;
        };
        iconTheme = {
          name = "TokyoNight-SE";
          package = tokyo-night-icons;
        };
      };
      home.pointerCursor = {
        gtk.enable = true;
        package = pkgs.bibata-cursors;
        name = "Bibata-Modern-Classic";
        size = 24;
      };
      home.stateVersion = "23.05";
    };
  system.stateVersion = "23.05";
}
1 Like

qtct works because HM rewrites it to qt5ct automatically: qt.nix
That was originally added in d214b93, which is from June and not yet in any stable HM branch though, so if you’re on NixOS+HM stable it won’t yet work.

Yes, I’m using stable 23.05 ( since yesterday it deprecated ).

you shouldn’t be configuring a qt theme inside nixpkgs.config, this is bad advice and I have my doubts as if this actually worked or not.

I could not get the nixos option qt style to work.

So this is how I do it, with nixos unstable 24.05 and it works.

/etc/nixos/configuration.nix

environment.systemPackages = with pkgs; [
      adwaita-qt
   ];

environment.sessionVariables = {
QT_STYLE_OVERRIDE = "adwaita-dark";
};