{ lib, config, ... }: let inherit (lib) types mkEnableOption mkIf optionalString boolToString ; inherit (lib.metacfg) mkOpt mkBoolOpt; cfg = config.metacfg.tools.wezterm; in { options.metacfg.tools.wezterm = { enable = mkEnableOption "wezterm config"; fontSize = mkOpt types.int 14 "Font size for wezterm."; enableKittyKeyboard = mkBoolOpt true "Enable the kitty keyboard protocol."; enableScrollBar = mkBoolOpt true "Enable the scroll bar."; backgroundImage = mkOpt (types.nullOr types.path) null "Path to a window background image."; term = mkOpt types.str "wezterm" "Value to set for `config.term`."; extraConfig = mkOpt types.lines "" "Extra Lua appended before `return config`."; }; config = mkIf cfg.enable { xdg.configFile."wezterm/wezterm.lua".text = '' local wezterm = require("wezterm") local config = wezterm.config_builder() config.enable_kitty_keyboard = ${boolToString cfg.enableKittyKeyboard} config.enable_scroll_bar = ${boolToString cfg.enableScrollBar} ${optionalString ( cfg.backgroundImage != null ) "config.window_background_image = '${cfg.backgroundImage}'"} config.font_size = ${toString cfg.fontSize} config.term = '${cfg.term}' ${cfg.extraConfig} return config ''; }; }