2019-03-11 00:45:49 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.programs.alacritty;
|
2023-12-28 12:07:30 +01:00
|
|
|
tomlFormat = pkgs.formats.toml { };
|
2020-02-02 00:39:17 +01:00
|
|
|
in {
|
2019-03-11 00:45:49 +01:00
|
|
|
options = {
|
|
|
|
programs.alacritty = {
|
2023-07-02 01:45:18 +02:00
|
|
|
enable = mkEnableOption "Alacritty";
|
2019-03-11 00:45:49 +01:00
|
|
|
|
2020-07-03 19:09:35 +02:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.alacritty;
|
2021-10-09 11:14:08 +02:00
|
|
|
defaultText = literalExpression "pkgs.alacritty";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "The Alacritty package to install.";
|
2020-07-03 19:09:35 +02:00
|
|
|
};
|
|
|
|
|
2019-03-11 00:45:49 +01:00
|
|
|
settings = mkOption {
|
2023-12-28 12:07:30 +01:00
|
|
|
type = tomlFormat.type;
|
2020-02-02 00:39:17 +01:00
|
|
|
default = { };
|
2021-10-09 11:14:08 +02:00
|
|
|
example = literalExpression ''
|
2019-03-11 00:45:49 +01:00
|
|
|
{
|
|
|
|
window.dimensions = {
|
|
|
|
lines = 3;
|
|
|
|
columns = 200;
|
|
|
|
};
|
2023-12-28 12:07:30 +01:00
|
|
|
keyboard.bindings = [
|
2019-03-11 00:45:49 +01:00
|
|
|
{
|
|
|
|
key = "K";
|
|
|
|
mods = "Control";
|
2024-04-19 16:26:23 +02:00
|
|
|
chars = "\\u000c";
|
2019-03-11 00:45:49 +01:00
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
'';
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2019-03-11 00:45:49 +01:00
|
|
|
Configuration written to
|
2023-12-28 12:07:30 +01:00
|
|
|
{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.
|
2019-03-11 00:45:49 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-12-28 12:07:30 +01:00
|
|
|
config = mkIf cfg.enable {
|
|
|
|
home.packages = [ cfg.package ];
|
2019-03-11 00:45:49 +01:00
|
|
|
|
2024-04-19 16:57:02 +02:00
|
|
|
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?
|
2024-09-11 18:16:19 +02:00
|
|
|
"substituteInPlace $out --replace-quiet '\\\\' '\\'"
|
2024-04-19 16:57:02 +02:00
|
|
|
];
|
|
|
|
});
|
|
|
|
};
|
2023-12-28 12:07:30 +01:00
|
|
|
};
|
2019-03-11 00:45:49 +01:00
|
|
|
}
|