depot/third_party/home-manager/modules/programs/alacritty.nix
Default email 4d19ca4703 Project import generated by Copybara.
GitOrigin-RevId: a7117efb3725e6197dd95424136f79147aa35e5b
2024-06-04 11:23:39 -07:00

64 lines
1.7 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.alacritty;
tomlFormat = pkgs.formats.toml { };
in {
options = {
programs.alacritty = {
enable = mkEnableOption "Alacritty";
package = mkOption {
type = types.package;
default = pkgs.alacritty;
defaultText = literalExpression "pkgs.alacritty";
description = "The Alacritty package to install.";
};
settings = mkOption {
type = tomlFormat.type;
default = { };
example = literalExpression ''
{
window.dimensions = {
lines = 3;
columns = 200;
};
keyboard.bindings = [
{
key = "K";
mods = "Control";
chars = "\\u000c";
}
];
}
'';
description = ''
Configuration written to
{file}`$XDG_CONFIG_HOME/alacritty/alacritty.yml` or
{file}`$XDG_CONFIG_HOME/alacritty/alacritty.toml`
(the latter being used for alacritty 0.13 and later).
See <https://github.com/alacritty/alacritty/tree/master#configuration>
for more info.
'';
};
};
};
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
xdg.configFile."alacritty/alacritty.toml" = lib.mkIf (cfg.settings != { }) {
source = (tomlFormat.generate "alacritty.toml" cfg.settings).overrideAttrs
(finalAttrs: prevAttrs: {
buildCommand = lib.concatStringsSep "\n" [
prevAttrs.buildCommand
# TODO: why is this needed? Is there a better way to retain escape sequences?
"substituteInPlace $out --replace '\\\\' '\\'"
];
});
};
};
}