mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
fcitx5: refactor logic (#6886)
* fcitx5: use mapAttrsToList instead of mapAttrs + attrValues * fcitx5: refactor xdg dataFile logic
This commit is contained in:
parent
f1aabf1deb
commit
68bc080cdf
1 changed files with 30 additions and 32 deletions
|
|
@ -100,39 +100,37 @@ in
|
||||||
sessionSearchVariables.QT_PLUGIN_PATH = [ "${fcitx5Package}/${pkgs.qt6.qtbase.qtPluginPrefix}" ];
|
sessionSearchVariables.QT_PLUGIN_PATH = [ "${fcitx5Package}/${pkgs.qt6.qtbase.qtPluginPrefix}" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
xdg =
|
xdg = lib.mkMerge (
|
||||||
let
|
[
|
||||||
mkThemeConfig = name: attrs: {
|
(lib.mkIf (cfg.classicUiConfig != "") {
|
||||||
dataFile = {
|
dataFile."fcitx5/conf/classicui.conf".source = (
|
||||||
"fcitx5/themes/${name}/highlight.svg" = lib.mkIf (attrs.highlightImage != null) {
|
if builtins.isPath cfg.classicUiConfig || lib.isStorePath cfg.classicUiConfig then
|
||||||
source = attrs.highlightImage;
|
cfg.classicUiConfig
|
||||||
};
|
else
|
||||||
"fcitx5/themes/${name}/panel.svg" = lib.mkIf (attrs.panelImage != null) {
|
pkgs.writeText "fcitx5-classicui.conf" cfg.classicUiConfig
|
||||||
source = attrs.panelImage;
|
);
|
||||||
};
|
})
|
||||||
"fcitx5/themes/${name}/theme.conf" = lib.mkIf (attrs.theme != null) {
|
]
|
||||||
source =
|
++ lib.mapAttrsToList (name: attrs: {
|
||||||
if builtins.isPath attrs.theme || lib.isStorePath attrs.theme then
|
dataFile =
|
||||||
attrs.theme
|
let
|
||||||
else
|
nullableFile =
|
||||||
pkgs.writeText "fcitx5-theme.conf" attrs.theme;
|
n: maybeNull: source:
|
||||||
};
|
lib.nameValuePair "fcitx5/themes/${name}/${n}" (lib.mkIf (maybeNull != null) { inherit source; });
|
||||||
};
|
simpleFile = n: v: nullableFile n v v;
|
||||||
};
|
in
|
||||||
in
|
builtins.listToAttrs [
|
||||||
lib.mkMerge (
|
(simpleFile "highlight.svg" attrs.highlightImage)
|
||||||
[
|
(simpleFile "panel.svg" attrs.panelImage)
|
||||||
(lib.mkIf (cfg.classicUiConfig != "") {
|
(nullableFile "theme.conf" attrs.theme (
|
||||||
dataFile."fcitx5/conf/classicui.conf".source = (
|
if builtins.isPath attrs.theme || lib.isStorePath attrs.theme then
|
||||||
if builtins.isPath cfg.classicUiConfig || lib.isStorePath cfg.classicUiConfig then
|
attrs.theme
|
||||||
cfg.classicUiConfig
|
|
||||||
else
|
else
|
||||||
pkgs.writeText "fcitx5-classicui.conf" cfg.classicUiConfig
|
pkgs.writeText "fcitx5-theme.conf" attrs.theme
|
||||||
);
|
))
|
||||||
})
|
];
|
||||||
]
|
}) cfg.themes
|
||||||
++ (builtins.attrValues (lib.mapAttrs mkThemeConfig cfg.themes))
|
);
|
||||||
);
|
|
||||||
|
|
||||||
systemd.user.services.fcitx5-daemon = {
|
systemd.user.services.fcitx5-daemon = {
|
||||||
Unit = {
|
Unit = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue