1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-12-12 20:11:06 +01:00

qt: added qt{5,6}ctSettings options (#8271)

Added qtctSettings option to qt module to make it possible to configure qt(5/6)ct declaratively.
This commit is contained in:
Viktor Titov 2025-12-08 10:17:30 +05:00 committed by GitHub
parent 082822b8a6
commit f9d45d664e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 90 additions and 1 deletions

View file

@ -8,6 +8,10 @@
let let
cfg = config.qt; cfg = config.qt;
qtctFormat = pkgs.formats.ini {
listToValue = values: lib.concatStringsSep ", " values;
};
# Map platform names to their packages. # Map platform names to their packages.
platformPackages = with pkgs; { platformPackages = with pkgs; {
gnome = [ gnome = [
@ -286,7 +290,34 @@ in
''; '';
}; };
}; };
}; }
// (lib.genAttrs' [ "qt5ct" "qt6ct" ] (
name:
lib.nameValuePair "${name}Settings" (
lib.mkOption {
type = lib.types.nullOr qtctFormat.type;
default = null;
example = lib.literalExpression ''
{
Appearance = {
style = "kvantum";
icon_theme = "Papirus-Dark";
standar_dialogs = "xdgdesktopportal";
};
Fonts = {
fixed = "\"DejaVuSansM Nerd Font Mono,12\"";
general = "\"DejaVu Sans,12\"";
};
}
'';
description = ''
Qtct configuration. Writes settings to `${name}/${name}.conf`
file. Lists will be translated to comma-separated strings.
Fonts must be quoted (see example).
'';
}
)
));
}; };
config = config =
@ -397,5 +428,18 @@ in
] ]
++ lib.optionals (platformTheme.name != null) [ "QT_QPA_PLATFORMTHEME" ] ++ lib.optionals (platformTheme.name != null) [ "QT_QPA_PLATFORMTHEME" ]
++ lib.optionals (cfg.style.name != null) [ "QT_STYLE_OVERRIDE" ]; ++ lib.optionals (cfg.style.name != null) [ "QT_STYLE_OVERRIDE" ];
xdg.configFile =
lib.pipe
[ "qt5ct" "qt6ct" ]
[
(lib.filter (qtct: cfg."${qtct}Settings" != null))
(lib.flip lib.genAttrs' (
qtct:
lib.nameValuePair "${qtct}/${qtct}.conf" {
source = qtctFormat.generate "${qtct}-config" cfg."${qtct}Settings";
}
))
];
}; };
} }

View file

@ -4,4 +4,7 @@
qt-platform-theme-gtk3 = ./qt-platform-theme-gtk3.nix; qt-platform-theme-gtk3 = ./qt-platform-theme-gtk3.nix;
qt-platform-theme-gnome = ./qt-platform-theme-gnome.nix; qt-platform-theme-gnome = ./qt-platform-theme-gnome.nix;
qt-platform-theme-kde6-migration = ./qt-platform-theme-kde6-migration.nix; qt-platform-theme-kde6-migration = ./qt-platform-theme-kde6-migration.nix;
qt-qt5ct-settings = ./qt-qt5ct-settings.nix;
qt-qt6ct-settings = ./qt-qt6ct-settings.nix;
qt-qtct-settings = ./qt-qtct-settings.nix;
} }

View file

@ -0,0 +1,13 @@
{
qt = {
enable = true;
qt5ctSettings = {
test_section.test_option = "test";
};
};
nmt.script = ''
assertFileExists "home-files/.config/qt5ct/qt5ct.conf"
assertPathNotExists "home-files/.config/qt6ct/qt6ct.conf"
'';
}

View file

@ -0,0 +1,13 @@
{
qt = {
enable = true;
qt6ctSettings = {
test_section.test_option = "test";
};
};
nmt.script = ''
assertFileExists "home-files/.config/qt6ct/qt6ct.conf"
assertPathNotExists "home-files/.config/qt5ct/qt5ct.conf"
'';
}

View file

@ -0,0 +1,16 @@
{
qt = {
enable = true;
qt5ctSettings = {
test_section.test_option = "test";
};
qt6ctSettings = {
test_section.test_option = "test";
};
};
nmt.script = ''
assertFileExists "home-files/.config/qt5ct/qt5ct.conf"
assertFileExists "home-files/.config/qt6ct/qt6ct.conf"
'';
}