{ config, lib, pkgs, ... }: with lib; let cfg = config.programs.fuzzel; iniFormat = pkgs.formats.ini {}; in { options = { programs.fuzzel = { enable = mkEnableOption "Fuzzel"; package = mkOption { type = types.package; default = pkgs.fuzzel; defaultText = literalExpression "pkgs.fuzzel"; description = "The Fuzzel package to install."; }; settings = mkOption { type = iniFormat.type; default = {}; example = literalExpression '' { window.dimensions = { lines = 3; columns = 200; }; key_bindings = [ { key = "K"; mods = "Control"; chars = "\\x0c"; } ]; } ''; description = '' Configuration written to $XDG_CONFIG_HOME/fuzzel/fuzzel.ini. ''; }; }; }; config = mkMerge [ (mkIf cfg.enable { home.packages = [cfg.package]; xdg.configFile."fuzzel/fuzzel.ini" = mkIf (cfg.settings != {}) { # TODO: Replace by the generate function but need to figure out how to # handle the escaping first. # # source = yamlFormat.generate "alacritty.yml" cfg.settings; text = replaceStrings ["\\\\"] ["\\"] (builtins.toJSON cfg.settings); }; }) ]; }