From 31df523787aeb3feb45ba68d491f732f759032a3 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Mon, 27 Apr 2026 09:47:46 +0200 Subject: [PATCH] refactor(home): extract shared wezterm module Add a `metacfg.tools.wezterm` home-manager module so wezterm.lua configuration can be reused across hosts instead of being duplicated inline. Migrate halo and amd to the new module and enable it on rialo (font size 14, term = xterm-256color). --- homes/aarch64-darwin/harald@rialo/default.nix | 4 ++ homes/x86_64-linux/harald@amd/default.nix | 18 ++------ homes/x86_64-linux/harald@halo/default.nix | 18 ++------ modules/home/tools/wezterm/default.nix | 46 +++++++++++++++++++ 4 files changed, 58 insertions(+), 28 deletions(-) create mode 100644 modules/home/tools/wezterm/default.nix diff --git a/homes/aarch64-darwin/harald@rialo/default.nix b/homes/aarch64-darwin/harald@rialo/default.nix index 02f2130..793071b 100644 --- a/homes/aarch64-darwin/harald@rialo/default.nix +++ b/homes/aarch64-darwin/harald@rialo/default.nix @@ -32,6 +32,10 @@ enable = true; userEmail = "harald@subzero.xyz"; }; + wezterm = { + enable = true; + term = "xterm-256color"; + }; }; }; diff --git a/homes/x86_64-linux/harald@amd/default.nix b/homes/x86_64-linux/harald@amd/default.nix index 9f5f8e1..088b662 100644 --- a/homes/x86_64-linux/harald@amd/default.nix +++ b/homes/x86_64-linux/harald@amd/default.nix @@ -20,6 +20,10 @@ }; tools = { git.enable = true; + wezterm = { + enable = true; + backgroundImage = ./terminal-background.png; + }; }; gui.kbd.ellipsis = true; }; @@ -71,18 +75,4 @@ xdg.enable = true; xdg.mime.enable = true; - - xdg.configFile."wezterm/wezterm.lua".text = '' - local wezterm = require("wezterm") - local config = wezterm.config_builder() - local act = wezterm.action - - config.enable_kitty_keyboard = true - config.enable_scroll_bar = true - config.window_background_image = '${./terminal-background.png}' - - config.term = 'wezterm' - - return config - ''; } diff --git a/homes/x86_64-linux/harald@halo/default.nix b/homes/x86_64-linux/harald@halo/default.nix index 9f5f8e1..088b662 100644 --- a/homes/x86_64-linux/harald@halo/default.nix +++ b/homes/x86_64-linux/harald@halo/default.nix @@ -20,6 +20,10 @@ }; tools = { git.enable = true; + wezterm = { + enable = true; + backgroundImage = ./terminal-background.png; + }; }; gui.kbd.ellipsis = true; }; @@ -71,18 +75,4 @@ xdg.enable = true; xdg.mime.enable = true; - - xdg.configFile."wezterm/wezterm.lua".text = '' - local wezterm = require("wezterm") - local config = wezterm.config_builder() - local act = wezterm.action - - config.enable_kitty_keyboard = true - config.enable_scroll_bar = true - config.window_background_image = '${./terminal-background.png}' - - config.term = 'wezterm' - - return config - ''; } diff --git a/modules/home/tools/wezterm/default.nix b/modules/home/tools/wezterm/default.nix new file mode 100644 index 0000000..56c66ef --- /dev/null +++ b/modules/home/tools/wezterm/default.nix @@ -0,0 +1,46 @@ +{ + 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 + ''; + }; +}