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,27 +100,7 @@ in
|
|||
sessionSearchVariables.QT_PLUGIN_PATH = [ "${fcitx5Package}/${pkgs.qt6.qtbase.qtPluginPrefix}" ];
|
||||
};
|
||||
|
||||
xdg =
|
||||
let
|
||||
mkThemeConfig = name: attrs: {
|
||||
dataFile = {
|
||||
"fcitx5/themes/${name}/highlight.svg" = lib.mkIf (attrs.highlightImage != null) {
|
||||
source = attrs.highlightImage;
|
||||
};
|
||||
"fcitx5/themes/${name}/panel.svg" = lib.mkIf (attrs.panelImage != null) {
|
||||
source = attrs.panelImage;
|
||||
};
|
||||
"fcitx5/themes/${name}/theme.conf" = lib.mkIf (attrs.theme != null) {
|
||||
source =
|
||||
if builtins.isPath attrs.theme || lib.isStorePath attrs.theme then
|
||||
attrs.theme
|
||||
else
|
||||
pkgs.writeText "fcitx5-theme.conf" attrs.theme;
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
lib.mkMerge (
|
||||
xdg = lib.mkMerge (
|
||||
[
|
||||
(lib.mkIf (cfg.classicUiConfig != "") {
|
||||
dataFile."fcitx5/conf/classicui.conf".source = (
|
||||
|
|
@ -131,7 +111,25 @@ in
|
|||
);
|
||||
})
|
||||
]
|
||||
++ (builtins.attrValues (lib.mapAttrs mkThemeConfig cfg.themes))
|
||||
++ lib.mapAttrsToList (name: attrs: {
|
||||
dataFile =
|
||||
let
|
||||
nullableFile =
|
||||
n: maybeNull: source:
|
||||
lib.nameValuePair "fcitx5/themes/${name}/${n}" (lib.mkIf (maybeNull != null) { inherit source; });
|
||||
simpleFile = n: v: nullableFile n v v;
|
||||
in
|
||||
builtins.listToAttrs [
|
||||
(simpleFile "highlight.svg" attrs.highlightImage)
|
||||
(simpleFile "panel.svg" attrs.panelImage)
|
||||
(nullableFile "theme.conf" attrs.theme (
|
||||
if builtins.isPath attrs.theme || lib.isStorePath attrs.theme then
|
||||
attrs.theme
|
||||
else
|
||||
pkgs.writeText "fcitx5-theme.conf" attrs.theme
|
||||
))
|
||||
];
|
||||
}) cfg.themes
|
||||
);
|
||||
|
||||
systemd.user.services.fcitx5-daemon = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue