nix/pkgs/fuzzel.nix
2023-04-21 01:58:39 +10:00

63 lines
1.4 KiB
Nix

{
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
<filename>$XDG_CONFIG_HOME/fuzzel/fuzzel.ini</filename>.
'';
};
};
};
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);
};
})
];
}