alacritty: cleanup

This commit is contained in:
Sean Buckley 2022-01-02 02:33:54 -05:00
parent 06ce96a246
commit af509d8484

View file

@ -1,26 +1,38 @@
{ config, pkgs, lib, ... }: { config, lib, pkgs, ... }:
# alacritty.yml is needed in both <current-system>/sw/etc/ and /etc/, or
# it won't work correctly in some environments (at least plasma+wayland)
# That's why it's in systemPackages AND environment.etc.
# (November 2021)
let let
cfg = config.sconfig.alacritty; cfg = config.sconfig.alacritty;
configText = builtins.toJSON
{
env.TERM = "xterm-256color";
key_bindings = [
{ action = "ScrollHalfPageDown"; mods = "Shift"; key = "PageDown"; }
{ action = "ScrollHalfPageUp"; mods = "Shift"; key = "PageUp"; }
{ action = "SpawnNewInstance"; mods = "Control|Shift"; key = "N"; }
{ action = "SpawnNewInstance"; mods = "Control|Shift"; key = "T"; }
];
};
in in
{ {
options.sconfig.alacritty.enable = lib.mkEnableOption "Enable Alacritty"; options.sconfig.alacritty.enable = lib.mkEnableOption "Enable Alacritty";
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.etc."xdg/alacritty.yml".text = configText;
environment.systemPackages = [ environment.systemPackages = [
pkgs.alacritty pkgs.alacritty
(pkgs.writeTextFile { (pkgs.writeTextFile {
name = "alacritty.yml"; name = "alacritty.yml";
destination = "/etc/xdg/alacritty.yml"; destination = "/etc/xdg/alacritty.yml";
text = '' text = configText;
env:
TERM: xterm-256color
key_bindings:
- { key: N, mods: Control|Shift, action: SpawnNewInstance }
- { key: T, mods: Control|Shift, action: SpawnNewInstance }
- { key: PageUp, mods: Shift, action: ScrollHalfPageUp }
- { key: PageDown, mods: Shift, action: ScrollHalfPageDown }
'';
}) })
]; ];
@ -30,9 +42,5 @@ in
} }
[ -z "$VTE_VERSION" ] && PROMPT_COMMAND="_set_title; $PROMPT_COMMAND" [ -z "$VTE_VERSION" ] && PROMPT_COMMAND="_set_title; $PROMPT_COMMAND"
''; '';
environment.etc."xdg/alacritty.yml".source =
"/run/current-system/sw/etc/xdg/alacritty.yml";
}; };
} }