nix-dotfiles/modules/software/system/wezterm.nix
2025-05-18 23:05:26 -07:00

76 lines
2.4 KiB
Nix

{ lib, config, pkgs, inputs, system, ... }:
with lib;
let
cfg = config.modules.software.system.wezterm;
in {
options.modules.software.system.wezterm = {
enable = mkEnableOption "Enable wezterm, a blazingly fast terminal emulator";
package = mkOption {
type = types.package;
default = pkgs.wezterm;
example = "pkgs.wezterm";
};
};
config = mkIf cfg.enable {
hm.programs.wezterm = {
enable = true;
package = cfg.package;
extraConfig = let
fonts = config.modules.desktop.fonts.fonts;
in ''
local wezterm = require 'wezterm'
local act = wezterm.action
local config = {}
config.front_end = "WebGpu"
config.font = wezterm.font '${fonts.monospace.family}'
-- this is a hack to get the font size to be the same as the bitmap font
-- the size is in px, but wezterm uses pt, so we use a conversion
config.font_size = ${toString fonts.monospace.size} / (4 / 3)
config.freetype_load_flags = 'MONOCHROME'
config.enable_wayland = true
config.use_fancy_tab_bar = false
-- TODO: tiling acting WACK. these just make it even worse
--config.use_resize_increments = true
--config.initial_cols = 120
--config.initial_rows = 40
config.window_background_opacity = 0.8
${config.modules.desktop.themes.wezterm or ""}
config.window_frame = {
font = wezterm.font '${fonts.sansSerif.family}',
font_size = ${toString fonts.sansSerif.size}
}
config.mouse_bindings = {
-- Change the default click behavior so that it only selects
-- text and doesn't open hyperlinks
{
event = { Up = { streak = 1, button = 'Left' } },
mods = 'NONE',
action = act.CompleteSelection 'ClipboardAndPrimarySelection'
},
-- and make CTRL-Click open hyperlinks
{
event = { Up = { streak = 1, button = 'Left' } },
mods = 'CTRL',
action = act.OpenLinkAtMouseCursor
},
-- Disable the 'Down' event of CTRL-Click to avoid weird program behaviors
-- https://wezfurlong.org/wezterm/config/mouse.html#gotcha-on-binding-an-up-event-only
{
event = { Down = { streak = 1, button = 'Left' } },
mods = 'CTRL',
action = act.Nop
}
}
return config
'';
};
};
}