aboutsummaryrefslogtreecommitdiff
path: root/home-manager/modules/programs/alacritty.nix
blob: 69b9ea9673d98271cb9edef5c7aa2348fd92c0c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{ config, lib, pkgs, ... }:

with lib;

let

  cfg = config.programs.alacritty;

in {
  options = {
    programs.alacritty = {
      enable = mkEnableOption "Alacritty";

      settings = mkOption {
        type = types.attrs;
        default = { };
        example = literalExample ''
          {
            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 = [ pkgs.alacritty ];

      xdg.configFile."alacritty/alacritty.yml" = mkIf (cfg.settings != { }) {
        text =
          replaceStrings [ "\\\\" ] [ "\\" ] (builtins.toJSON cfg.settings);
      };
    })
  ];
}