From af509d8484736e359e9836174f927511e611d1c1 Mon Sep 17 00:00:00 2001 From: Sean Buckley Date: Sun, 2 Jan 2022 02:33:54 -0500 Subject: [PATCH] alacritty: cleanup --- modules/alacritty.nix | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/modules/alacritty.nix b/modules/alacritty.nix index 43dea59..5e7815e 100644 --- a/modules/alacritty.nix +++ b/modules/alacritty.nix @@ -1,26 +1,38 @@ -{ config, pkgs, lib, ... }: +{ config, lib, pkgs, ... }: + +# alacritty.yml is needed in both /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 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 { options.sconfig.alacritty.enable = lib.mkEnableOption "Enable Alacritty"; config = lib.mkIf cfg.enable { + environment.etc."xdg/alacritty.yml".text = configText; + environment.systemPackages = [ pkgs.alacritty (pkgs.writeTextFile { name = "alacritty.yml"; destination = "/etc/xdg/alacritty.yml"; - text = '' - 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 } - ''; + text = configText; }) ]; @@ -30,9 +42,5 @@ in } [ -z "$VTE_VERSION" ] && PROMPT_COMMAND="_set_title; $PROMPT_COMMAND" ''; - - environment.etc."xdg/alacritty.yml".source = - "/run/current-system/sw/etc/xdg/alacritty.yml"; - }; }