2020-10-12 00:22:58 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.programs.alacritty;
|
2021-07-02 22:36:30 +00:00
|
|
|
yamlFormat = pkgs.formats.yaml { };
|
2020-10-12 00:22:58 +00:00
|
|
|
in {
|
|
|
|
options = {
|
|
|
|
programs.alacritty = {
|
|
|
|
enable = mkEnableOption "Alacritty";
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.alacritty;
|
2021-11-04 16:42:44 +00:00
|
|
|
defaultText = literalExpression "pkgs.alacritty";
|
2020-10-12 00:22:58 +00:00
|
|
|
description = "The Alacritty package to install.";
|
|
|
|
};
|
|
|
|
|
|
|
|
settings = mkOption {
|
2021-07-02 22:36:30 +00:00
|
|
|
type = yamlFormat.type;
|
2020-10-12 00:22:58 +00:00
|
|
|
default = { };
|
2021-11-04 16:42:44 +00:00
|
|
|
example = literalExpression ''
|
2020-10-12 00:22:58 +00:00
|
|
|
{
|
|
|
|
window.dimensions = {
|
|
|
|
lines = 3;
|
|
|
|
columns = 200;
|
|
|
|
};
|
|
|
|
key_bindings = [
|
|
|
|
{
|
|
|
|
key = "K";
|
|
|
|
mods = "Control";
|
|
|
|
chars = "\\x0c";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Configuration written to
|
|
|
|
<filename>~/.config/alacritty/alacritty.yml</filename>. See
|
|
|
|
<link xlink:href="https://github.com/jwilm/alacritty/blob/master/alacritty.yml"/>
|
|
|
|
for the default configuration.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkMerge [
|
|
|
|
(mkIf cfg.enable {
|
|
|
|
home.packages = [ cfg.package ];
|
|
|
|
|
|
|
|
xdg.configFile."alacritty/alacritty.yml" = mkIf (cfg.settings != { }) {
|
2021-07-02 22:36:30 +00:00
|
|
|
# TODO: Replace by the generate function but need to figure out how to
|
|
|
|
# handle the escaping first.
|
|
|
|
#
|
|
|
|
# source = yamlFormat.generate "alacritty.yml" cfg.settings;
|
|
|
|
|
2020-10-12 00:22:58 +00:00
|
|
|
text =
|
|
|
|
replaceStrings [ "\\\\" ] [ "\\" ] (builtins.toJSON cfg.settings);
|
|
|
|
};
|
|
|
|
})
|
|
|
|
];
|
|
|
|
}
|