Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qt: add flexible theming with sensible defaults #780

Merged
merged 15 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions modules/qt/hm.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
pkgs,
config,
lib,
...
}:
{
options.stylix.targets.qt = {
enable = config.lib.stylix.mkEnableTarget "QT" pkgs.stdenv.hostPlatform.isLinux;
platform = lib.mkOption {
description = ''
Platform for QT.
Mikilio marked this conversation as resolved.
Show resolved Hide resolved

Defaults to the standard platform of the configured DE in NixOS when
`stylix.homeManagerIntegration.followSystem = true`.

Fallback to qtct.
Mikilio marked this conversation as resolved.
Show resolved Hide resolved
'';
type = lib.types.str;
default = "qtct";
};
};

config = lib.mkIf config.stylix.targets.qt.enable (
let
cfg = config.stylix;
Mikilio marked this conversation as resolved.
Show resolved Hide resolved
iconTheme =
if (cfg.polarity == "dark") then cfg.iconTheme.dark else cfg.iconTheme.light;
trueNAHO marked this conversation as resolved.
Show resolved Hide resolved

recommendedStyle = {
gnome = if config.stylix.polarity == "dark" then "adwaita-dark" else "adwaita";
kde = "breeze";
qtct = "kvantum";
};
Mikilio marked this conversation as resolved.
Show resolved Hide resolved

kvantumPackage =
let
kvconfig = config.lib.stylix.colors {
template = ./kvconfig.mustache;
extension = ".kvconfig";
};
svg = config.lib.stylix.colors {
template = ./kvantum-svg.mustache;
extension = "svg";
};
in
pkgs.runCommandLocal "base16-kvantum" { } ''
directory="$out/share/Kvantum/Base16Kvantum"
mkdir --parents "$directory"
ln -s ${kvconfig} "$directory/Base16Kvantum.kvconfig"
ln -s ${svg} "$directory/Base16Kvantum.svg"
Mikilio marked this conversation as resolved.
Show resolved Hide resolved
'';
in
{
warnings = lib.optional (cfg.targets.qt.platform != "qtct") ''
Stylix has not yet implemented qt styling for any platforms other than "qtct".
We are working on it.
'';
Mikilio marked this conversation as resolved.
Show resolved Hide resolved

home.packages = lib.optional (config.qt.style.name == "kvantum") kvantumPackage;

qt = {
enable = true;
style.name = lib.mkIf (
recommendedStyle ? "${config.qt.platformTheme.name}"
) recommendedStyle."${config.qt.platformTheme.name}";
Mikilio marked this conversation as resolved.
Show resolved Hide resolved
platformTheme.name = cfg.targets.qt.platform;
};

xdg.configFile = lib.mkMerge [
(lib.mkIf (config.qt.style.name == "kvantum") {
"Kvantum/kvantum.kvconfig".source =
(pkgs.formats.ini { }).generate "kvantum.kvconfig"
{
General.theme = "Base16Kvantum";
};
Mikilio marked this conversation as resolved.
Show resolved Hide resolved

"Kvantum/Base16Kvantum".source =
"${kvantumPackage}/share/Kvantum/Base16Kvantum";
})

(lib.mkIf (config.qt.platformTheme.name == "qtct") {
"qt5ct/qt5ct.conf".text = ''
[Appearance]
style=${config.qt.style.name}
icon_theme=${iconTheme}
'';
"qt6ct/qt6ct.conf".text = ''
[Appearance]
style=${config.qt.style.name}
icon_theme=${iconTheme}
'';
})
];
}
);
}
Loading
Loading