2019-03-10 23:45:49 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.programs.alacritty;
|
2020-11-30 02:54:55 +00:00
|
|
|
yamlFormat = pkgs.formats.yaml { };
|
2020-02-01 23:39:17 +00:00
|
|
|
in {
|
2019-03-10 23:45:49 +00:00
|
|
|
options = {
|
|
|
|
programs.alacritty = {
|
|
|
|
enable = mkEnableOption "Alacritty";
|
|
|
|
|
2020-07-03 17:09:35 +00:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.alacritty;
|
2021-10-09 09:14:08 +00:00
|
|
|
defaultText = literalExpression "pkgs.alacritty";
|
2020-07-03 17:09:35 +00:00
|
|
|
description = "The Alacritty package to install.";
|
|
|
|
};
|
|
|
|
|
2019-03-10 23:45:49 +00:00
|
|
|
settings = mkOption {
|
2020-11-30 02:54:55 +00:00
|
|
|
type = yamlFormat.type;
|
2020-02-01 23:39:17 +00:00
|
|
|
default = { };
|
2021-10-09 09:14:08 +00:00
|
|
|
example = literalExpression ''
|
2019-03-10 23:45:49 +00:00
|
|
|
{
|
|
|
|
window.dimensions = {
|
|
|
|
lines = 3;
|
|
|
|
columns = 200;
|
|
|
|
};
|
|
|
|
key_bindings = [
|
|
|
|
{
|
|
|
|
key = "K";
|
|
|
|
mods = "Control";
|
|
|
|
chars = "\\x0c";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Configuration written to
|
2021-12-09 03:02:00 +00:00
|
|
|
<filename>$XDG_CONFIG_HOME/alacritty/alacritty.yml</filename>. See
|
2021-12-28 17:09:37 +00:00
|
|
|
<link xlink:href="https://github.com/alacritty/alacritty/blob/master/alacritty.yml"/>
|
2019-03-10 23:45:49 +00:00
|
|
|
for the default configuration.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-05-13 02:08:23 +00:00
|
|
|
config = mkMerge [
|
|
|
|
(mkIf cfg.enable {
|
2020-07-03 17:09:35 +00:00
|
|
|
home.packages = [ cfg.package ];
|
2019-03-10 23:45:49 +00:00
|
|
|
|
2020-02-01 23:39:17 +00:00
|
|
|
xdg.configFile."alacritty/alacritty.yml" = mkIf (cfg.settings != { }) {
|
2020-11-30 02:54:55 +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-02-01 23:39:17 +00:00
|
|
|
text =
|
|
|
|
replaceStrings [ "\\\\" ] [ "\\" ] (builtins.toJSON cfg.settings);
|
2019-05-13 02:08:23 +00:00
|
|
|
};
|
|
|
|
})
|
|
|
|
];
|
2019-03-10 23:45:49 +00:00
|
|
|
}
|