1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-03-07 01:07:00 +00:00
home-manager/modules/programs/wezterm.nix
NAHO 5af1b9a0f1
treewide: standardize shell integration options
Standardize all 'programs.<PROGRAM>.enable<SHELL>Integration' options
with the following new functions:

- lib.hm.shell.mkBashIntegrationOption
- lib.hm.shell.mkFishIntegrationOption
- lib.hm.shell.mkIonIntegrationOption
- lib.hm.shell.mkNushellIntegrationOption
- lib.hm.shell.mkZshIntegrationOption

These functions should default to their corresponding global option:

- home.shell.enableBashIntegration
- home.shell.enableFishIntegration
- home.shell.enableIonIntegration
- home.shell.enableNushellIntegration
- home.shell.enableZshIntegration

All these global options default to the
'home.shell.enableShellIntegration' value.

This hierarchy standardizes the shell integration and increases end-user
flexibility.

BREAKING CHANGE: The following inconsistent default values change from
'false' to 'true':

- programs.zellij.enableBashIntegration
- programs.zellij.enableFishIntegration
- programs.zellij.enableZshIntegration

Link: https://github.com/nix-community/home-manager/pull/6358

Co-authored-by: Robert Helgesson <robert@rycee.net>
2025-02-08 22:49:40 +01:00

113 lines
3.4 KiB
Nix

{ config, lib, pkgs, ... }:
let
inherit (lib) literalExpression mkIf mkEnableOption mkOption types;
cfg = config.programs.wezterm;
tomlFormat = pkgs.formats.toml { };
shellIntegrationStr = ''
source "${cfg.package}/etc/profile.d/wezterm.sh"
'';
in {
meta.maintainers = [ lib.hm.maintainers.blmhemu lib.maintainers.khaneliman ];
options.programs.wezterm = {
enable = mkEnableOption "wezterm";
package = mkOption {
type = types.package;
default = pkgs.wezterm;
defaultText = literalExpression "pkgs.wezterm";
description = "The Wezterm package to install.";
};
extraConfig = mkOption {
type = types.lines;
default = ''
return {}
'';
example = literalExpression ''
-- Your lua code / config here
local mylib = require 'mylib';
return {
usemylib = mylib.do_fun();
font = wezterm.font("JetBrains Mono"),
font_size = 16.0,
color_scheme = "Tomorrow Night",
hide_tab_bar_if_only_one_tab = true,
default_prog = { "zsh", "--login", "-c", "tmux attach -t dev || tmux new -s dev" },
keys = {
{key="n", mods="SHIFT|CTRL", action="ToggleFullScreen"},
}
}
'';
description = ''
Extra configuration written to
{file}`$XDG_CONFIG_HOME/wezterm/wezterm.lua`. See
<https://wezfurlong.org/wezterm/config/files.html>
how to configure.
'';
};
colorSchemes = mkOption {
type = types.attrsOf (tomlFormat.type);
default = { };
example = literalExpression ''
myCoolTheme = {
ansi = [
"#222222" "#D14949" "#48874F" "#AFA75A"
"#599797" "#8F6089" "#5C9FA8" "#8C8C8C"
];
brights = [
"#444444" "#FF6D6D" "#89FF95" "#FFF484"
"#97DDFF" "#FDAAF2" "#85F5DA" "#E9E9E9"
];
background = "#1B1B1B";
cursor_bg = "#BEAF8A";
cursor_border = "#BEAF8A";
cursor_fg = "#1B1B1B";
foreground = "#BEAF8A";
selection_bg = "#444444";
selection_fg = "#E9E9E9";
};
'';
description = ''
Attribute set of additional color schemes to be written to
{file}`$XDG_CONFIG_HOME/wezterm/colors`, where each key is
taken as the name of the corresponding color scheme. See
<https://wezfurlong.org/wezterm/config/appearance.html#defining-a-color-scheme-in-a-separate-file>
for more details of the TOML color scheme format.
'';
};
enableBashIntegration =
lib.hm.shell.mkBashIntegrationOption { inherit config; };
enableZshIntegration =
lib.hm.shell.mkZshIntegrationOption { inherit config; };
};
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
xdg.configFile = {
"wezterm/wezterm.lua".text = ''
-- Generated by Home Manager.
-- See https://wezfurlong.org/wezterm/
local wezterm = require 'wezterm'
${cfg.extraConfig}
'';
} // lib.mapAttrs' (name: value:
lib.nameValuePair "wezterm/colors/${name}.toml" {
source = tomlFormat.generate "${name}.toml" { colors = value; };
}) cfg.colorSchemes;
programs.bash.initExtra =
mkIf cfg.enableBashIntegration shellIntegrationStr;
programs.zsh.initExtra = mkIf cfg.enableZshIntegration shellIntegrationStr;
};
}