All my system configs and packages in one repo
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

new(hm-plus): extended fcitx5 modules

+196 -176
+1
hm-plus/modules/programs/default.nix
··· 2 2 imports = [ 3 3 ./1password.nix 4 4 ./discord.nix 5 + ./fcitx5 5 6 ./git.nix 6 7 ./vesktop.nix 7 8 ];
+149
hm-plus/modules/programs/fcitx5/default.nix
··· 1 + { 2 + config, 3 + osConfig, 4 + lib, 5 + pkgs, 6 + ... 7 + }: let 8 + inherit (lib) mkMerge mkIf mkOption types literalExpression; 9 + im = config.i18n.inputMethod; 10 + cfg = im.fcitx5; 11 + 12 + fcitx5Package = 13 + if cfg.plasma6Support 14 + then pkgs.qt6Packages.fcitx5-with-addons.override {inherit (cfg) addons;} 15 + else pkgs.libsForQt5.fcitx5-with-addons; 16 + 17 + fcitx5Package' = fcitx5Package.override {inherit (cfg) addons;}; 18 + 19 + format = pkgs.formats.ini {}; 20 + formatWithGlobalSection = pkgs.formats.iniWithGlobalSection {}; 21 + in { 22 + imports = [./rime.nix]; 23 + 24 + options.i18n.inputMethod.fcitx5 = { 25 + waylandFrontend = mkOption { 26 + type = types.bool; 27 + default = false; 28 + description = '' 29 + Use the Wayland input method frontend. 30 + See [Using Fcitx 5 on Wayland](https://fcitx-im.org/wiki/Using_Fcitx_5_on_Wayland). 31 + ''; 32 + }; 33 + plasma6Support = mkOption { 34 + type = types.bool; 35 + default = osConfig.services.desktopManager.plasma6.enable; 36 + defaultText = literalExpression "config.services.desktopManager.plasma6.enable"; 37 + description = '' 38 + Use qt6 versions of fcitx5 packages. 39 + Required for configuring fcitx5 in KDE System Settings. 40 + ''; 41 + }; 42 + quickPhrase = mkOption { 43 + type = with types; attrsOf str; 44 + default = {}; 45 + example = literalExpression '' 46 + { 47 + smile = "(・∀・)"; 48 + angry = "( ̄ー ̄)"; 49 + } 50 + ''; 51 + description = "Quick phrases."; 52 + }; 53 + quickPhraseFiles = mkOption { 54 + type = with types; attrsOf path; 55 + default = {}; 56 + example = literalExpression '' 57 + { 58 + words = ./words.mb; 59 + numbers = ./numbers.mb; 60 + } 61 + ''; 62 + description = "Quick phrase files."; 63 + }; 64 + settings = { 65 + globalOptions = mkOption { 66 + type = types.submodule { 67 + freeformType = format.type; 68 + }; 69 + default = {}; 70 + description = '' 71 + The global options in `config` file in ini format. 72 + ''; 73 + }; 74 + inputMethod = mkOption { 75 + type = types.submodule { 76 + freeformType = format.type; 77 + }; 78 + default = {}; 79 + description = '' 80 + The input method configure in `profile` file in ini format. 81 + ''; 82 + }; 83 + addons = mkOption { 84 + type = with types; (attrsOf anything); 85 + default = {}; 86 + description = '' 87 + The addon configures in `conf` folder in ini format with global sections. 88 + Each item is written to the corresponding file. 89 + ''; 90 + example = literalExpression "{ pinyin.globalSection.EmojiEnabled = \"True\"; }"; 91 + }; 92 + }; 93 + ignoreUserConfig = lib.mkOption { 94 + type = lib.types.bool; 95 + default = false; 96 + description = '' 97 + Ignore the user configures. **Warning**: When this is enabled, the 98 + user config files are totally ignored and the user dict can't be saved 99 + and loaded. 100 + ''; 101 + }; 102 + }; 103 + 104 + config = mkIf (im.enabled == "fcitx5") { 105 + # override HM defaults 106 + i18n.inputMethod.package = lib.mkForce fcitx5Package'; 107 + 108 + i18n.inputMethod.fcitx5.addons = 109 + lib.optionals (cfg.quickPhrase != {}) [ 110 + (pkgs.writeTextDir "share/fcitx5/data/QuickPhrase.mb" 111 + (lib.concatStringsSep "\n" 112 + (lib.mapAttrsToList (name: value: "${name} ${value}") cfg.quickPhrase))) 113 + ] 114 + ++ lib.optionals (cfg.quickPhraseFiles != {}) [ 115 + (pkgs.linkFarm "quickPhraseFiles" (lib.mapAttrs' 116 + (name: value: lib.nameValuePair "share/fcitx5/data/quickphrase.d/${name}.mb" value) 117 + cfg.quickPhraseFiles)) 118 + ]; 119 + 120 + xdg.configFile = let 121 + optionalFile = p: f: v: 122 + lib.optionalAttrs (v != {}) { 123 + "fcitx5/${p}".source = f p v; 124 + }; 125 + in 126 + lib.attrsets.mergeAttrsList [ 127 + (optionalFile "config" format cfg.settings.globalOptions) 128 + (optionalFile "profile" format cfg.settings.inputMethod) 129 + (lib.concatMapAttrs 130 + (name: value: 131 + optionalFile 132 + "conf/${name}.conf" 133 + formatWithGlobalSection 134 + value) 135 + cfg.settings.addons) 136 + ]; 137 + 138 + home.sessionVariables = mkMerge [ 139 + (mkIf cfg.waylandFrontend { 140 + # TODO: bad fix 141 + GTK_IM_MODULE = ""; 142 + QT_IM_MODULE = ""; 143 + }) 144 + (mkIf cfg.ignoreUserConfig { 145 + SKIP_FCITX_USER_PATH = "1"; 146 + }) 147 + ]; 148 + }; 149 + }
-57
roles/fcitx5/default.nix
··· 1 - {lib, ...}: let 2 - inherit (lib) mkEnableOption mkOption types; 3 - 4 - settingsModule.options = let 5 - groupModule.options = { 6 - name = mkOption { 7 - type = types.str; 8 - default = "Default"; 9 - }; 10 - defaultLayout = mkOption { 11 - type = types.str; 12 - default = ""; 13 - }; 14 - defaultIM = mkOption { 15 - type = types.str; 16 - default = ""; 17 - }; 18 - items = mkOption { 19 - type = types.listOf (types.submodule itemModule); 20 - default = []; 21 - }; 22 - }; 23 - itemModule.options = { 24 - name = mkOption { 25 - type = types.str; 26 - }; 27 - layout = mkOption { 28 - type = types.str; 29 - default = ""; 30 - }; 31 - }; 32 - in { 33 - groups = mkOption { 34 - type = types.listOf (types.submodule groupModule); 35 - default = []; 36 - }; 37 - }; 38 - in { 39 - imports = [ 40 - ./rime 41 - (lib.mkAliasOptionModule ["roles" "fcitx5" "addons"] ["i18n" "inputMethod" "fcitx5" "addons"]) 42 - ]; 43 - 44 - options.roles.fcitx5 = { 45 - enable = mkEnableOption "Fcitx5"; 46 - 47 - theme = mkOption { 48 - type = types.nullOr types.str; 49 - default = null; 50 - }; 51 - 52 - settings = mkOption { 53 - type = types.nullOr (types.submodule settingsModule); 54 - default = null; 55 - }; 56 - }; 57 - }
-77
roles/fcitx5/nixos.nix
··· 1 - { 2 - config, 3 - lib, 4 - ... 5 - }: let 6 - inherit (lib) mkIf; 7 - cfg = config.roles.fcitx5; 8 - toINI = lib.generators.toINI {}; 9 - mkFcitx5Cfg = { 10 - groups ? [], 11 - groupOrder ? builtins.catAttrs "name" groups, 12 - }: let 13 - inherit (builtins) listToAttrs; 14 - inherit (lib) flatten imap0 nameValuePair; 15 - 16 - mapItem = { 17 - name, 18 - layout, 19 - ... 20 - }: { 21 - Name = name; 22 - Layout = layout; 23 - }; 24 - 25 - mapGroup = { 26 - name, 27 - defaultLayout, 28 - defaultIM, 29 - items, 30 - ... 31 - }: { 32 - Name = name; 33 - "Default Layout" = defaultLayout; 34 - DefaultIM = defaultIM; 35 - }; 36 - 37 - mkItems = i: g: 38 - imap0 ( 39 - n: item: 40 - nameValuePair "Groups/${toString i}/Items/${toString n}" (mapItem item) 41 - ) 42 - g.items; 43 - 44 - mkGroups = gs: 45 - flatten (imap0 (i: g: 46 - [(nameValuePair "Groups/${toString i}" (mapGroup g))] 47 - ++ mkItems i g) 48 - gs); 49 - 50 - mkGroupOrder = go: listToAttrs (imap0 (i: nameValuePair (toString i)) go); 51 - in 52 - toINI ( 53 - listToAttrs (mkGroups groups) // {GroupOrder = mkGroupOrder groupOrder;} 54 - ); 55 - in { 56 - config = mkIf cfg.enable { 57 - i18n.inputMethod = { 58 - enabled = "fcitx5"; 59 - 60 - fcitx5 = { 61 - waylandFrontend = true; 62 - plasma6Support = true; 63 - }; 64 - }; 65 - 66 - hm.i18n.inputMethod.enabled = "fcitx5"; 67 - 68 - hm.xdg.configFile = { 69 - "fcitx5/profile" = mkIf (cfg.settings != null) { 70 - text = mkFcitx5Cfg cfg.settings; 71 - }; 72 - "fcitx5/conf/classicui.conf" = mkIf (cfg.theme != null) { 73 - text = toINI {Theme = cfg.theme;}; 74 - }; 75 - }; 76 - }; 77 - }
+11 -10
roles/fcitx5/rime/default.nix hm-plus/modules/programs/fcitx5/rime.nix
··· 5 5 ... 6 6 }: let 7 7 inherit (lib) mkIf mkEnableOption mkOption mapAttrs' nameValuePair types; 8 - cfg = config.roles.fcitx5.rime; 9 - 10 - mkRimeCfgs = mapAttrs' ( 11 - n: v: 12 - nameValuePair "fcitx5/rime/${n}.custom.yaml" {text = lib.generators.toYAML {} v;} 13 - ); 8 + cfg = config.i18n.inputMethod.fcitx5.rime; 9 + format = pkgs.formats.yaml {}; 14 10 in { 15 - options.roles.fcitx5.rime = { 11 + options.i18n.inputMethod.fcitx5.rime = { 16 12 enable = mkEnableOption "the Rime input engine for Fcitx5"; 17 13 18 14 dataPkgs = mkOption { ··· 21 17 }; 22 18 23 19 settings = mkOption { 24 - type = types.attrsOf types.anything; 20 + inherit (format) type; 25 21 default = {}; 26 22 example = { 27 23 default.patch.schema_list = [ ··· 33 29 }; 34 30 35 31 config = mkIf cfg.enable { 36 - roles.fcitx5.addons = [ 32 + i18n.inputMethod.fcitx5.addons = [ 37 33 (pkgs.fcitx5-rime.override { 38 34 rimeDataPkgs = cfg.dataPkgs; 39 35 }) 40 36 ]; 41 - hm.xdg.dataFile = mkRimeCfgs cfg.settings; 37 + xdg.dataFile = 38 + mapAttrs' ( 39 + n: v: 40 + nameValuePair "fcitx5/rime/${n}.custom.yaml" {source = format.generate n v;} 41 + ) 42 + cfg.settings; 42 43 }; 43 44 }
+35 -32
users/leah/programs/fcitx5/default.nix
··· 1 1 {pkgs, ...}: { 2 - roles.fcitx5 = { 3 - enable = true; 2 + hm.i18n.inputMethod = { 3 + enabled = "fcitx5"; 4 + fcitx5 = { 5 + addons = [pkgs.fcitx5-mozc]; 4 6 5 - addons = [pkgs.fcitx5-mozc]; 7 + catppuccin.enable = false; # TODO 6 8 7 - # settings.groups = [ 8 - # { 9 - # name = "Default"; 10 - # defaultLayout = "us"; 11 - # defaultIM = "keyboard-us"; 12 - # items = map (name: {inherit name;}) ["keyboard-us" "rime" "mozc"]; 13 - # } 14 - # ]; 9 + # settings.groups = [ 10 + # { 11 + # name = "Default"; 12 + # defaultLayout = "us"; 13 + # defaultIM = "keyboard-us"; 14 + # items = map (name: {inherit name;}) ["keyboard-us" "rime" "mozc"]; 15 + # } 16 + # ]; 15 17 16 - rime = { 17 - enable = true; 18 + rime = { 19 + enable = true; 18 20 19 - settings = let 20 - luna_pinyin.patch."speller/algebra" = [ 21 - "erase/^xx$/" 22 - "derive/in$/ing/" # in/ing 不分 23 - "derive/ing$/in/" 21 + settings = let 22 + luna_pinyin.patch."speller/algebra" = [ 23 + "erase/^xx$/" 24 + "derive/in$/ing/" # in/ing 不分 25 + "derive/ing$/in/" 24 26 25 - # 非标拼写 26 - "derive/^([nl])ve$/$1ue/" # nve = nue, lve = lue 27 - "derive/^([jqxy])v/$1u/" # ju = jv 28 - "derive/uen$/un/" # gun = guen 29 - "derive/uei$/ui/" # gui = guei 30 - "derive/iou$/iu/" # jiu = jiou 31 - ]; 32 - in { 33 - default.patch.schema_list = [ 34 - {schema = "luna_pinyin_simp";} 35 - {schema = "luna_pinyin";} 36 - ]; 37 - inherit luna_pinyin; 38 - luna_pinyin_simp = luna_pinyin; 27 + # 非标拼写 28 + "derive/^([nl])ve$/$1ue/" # nve = nue, lve = lue 29 + "derive/^([jqxy])v/$1u/" # ju = jv 30 + "derive/uen$/un/" # gun = guen 31 + "derive/uei$/ui/" # gui = guei 32 + "derive/iou$/iu/" # jiu = jiou 33 + ]; 34 + in { 35 + default.patch.schema_list = [ 36 + {schema = "luna_pinyin_simp";} 37 + {schema = "luna_pinyin";} 38 + ]; 39 + inherit luna_pinyin; 40 + luna_pinyin_simp = luna_pinyin; 41 + }; 39 42 }; 40 43 }; 41 44 };