1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-27 12:19:48 +01:00
home-manager/modules/programs/alacritty.nix

64 lines
1.6 KiB
Nix
Raw Normal View History

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