fork/home-manager

git clone https://git.julia.blue/fork/home-manager

NAHOwezterm: remove automatic config reload callf92a54fe

master
3.3 KiB116 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7  cfg = config.programs.wezterm;
8  tomlFormat = pkgs.formats.toml { };
9
10  shellIntegrationStr = ''
11    source "${cfg.package}/etc/profile.d/wezterm.sh"
12  '';
13
14in {
15  meta.maintainers = [ hm.maintainers.blmhemu ];
16
17  options.programs.wezterm = {
18    enable = mkEnableOption "wezterm";
19
20    package = mkOption {
21      type = types.package;
22      default = pkgs.wezterm;
23      defaultText = literalExpression "pkgs.wezterm";
24      description = "The Wezterm package to install.";
25    };
26
27    extraConfig = mkOption {
28      type = types.lines;
29      default = ''
30        return {}
31      '';
32      example = literalExpression ''
33        -- Your lua code / config here
34        local mylib = require 'mylib';
35        return {
36          usemylib = mylib.do_fun();
37          font = wezterm.font("JetBrains Mono"),
38          font_size = 16.0,
39          color_scheme = "Tomorrow Night",
40          hide_tab_bar_if_only_one_tab = true,
41          default_prog = { "zsh", "--login", "-c", "tmux attach -t dev || tmux new -s dev" },
42          keys = {
43            {key="n", mods="SHIFT|CTRL", action="ToggleFullScreen"},
44          }
45        }
46      '';
47      description = ''
48        Extra configuration written to
49        {file}`$XDG_CONFIG_HOME/wezterm/wezterm.lua`. See
50        <https://wezfurlong.org/wezterm/config/files.html>
51        how to configure.
52      '';
53    };
54
55    colorSchemes = mkOption {
56      type = types.attrsOf (tomlFormat.type);
57      default = { };
58      example = literalExpression ''
59        myCoolTheme = {
60          ansi = [
61            "#222222" "#D14949" "#48874F" "#AFA75A"
62            "#599797" "#8F6089" "#5C9FA8" "#8C8C8C"
63          ];
64          brights = [
65            "#444444" "#FF6D6D" "#89FF95" "#FFF484"
66            "#97DDFF" "#FDAAF2" "#85F5DA" "#E9E9E9"
67          ];
68          background = "#1B1B1B";
69          cursor_bg = "#BEAF8A";
70          cursor_border = "#BEAF8A";
71          cursor_fg = "#1B1B1B";
72          foreground = "#BEAF8A";
73          selection_bg = "#444444";
74          selection_fg = "#E9E9E9";
75        };
76      '';
77      description = ''
78        Attribute set of additional color schemes to be written to
79        {file}`$XDG_CONFIG_HOME/wezterm/colors`, where each key is
80        taken as the name of the corresponding color scheme. See
81        <https://wezfurlong.org/wezterm/config/appearance.html#defining-a-color-scheme-in-a-separate-file>
82        for more details of the TOML color scheme format.
83      '';
84    };
85
86    enableBashIntegration = mkEnableOption "WezTerm's Bash integration" // {
87      default = true;
88    };
89
90    enableZshIntegration = mkEnableOption "WezTerm's Zsh integration" // {
91      default = true;
92    };
93  };
94
95  config = mkIf cfg.enable {
96    home.packages = [ cfg.package ];
97
98    xdg.configFile = {
99      "wezterm/wezterm.lua".text = ''
100        -- Generated by Home Manager.
101        -- See https://wezfurlong.org/wezterm/
102
103        local wezterm = require 'wezterm';
104
105        ${cfg.extraConfig}
106      '';
107    } // mapAttrs' (name: value:
108      nameValuePair "wezterm/colors/${name}.toml" {
109        source = tomlFormat.generate "${name}.toml" { colors = value; };
110      }) cfg.colorSchemes;
111
112    programs.bash.initExtra =
113      mkIf cfg.enableBashIntegration shellIntegrationStr;
114    programs.zsh.initExtra = mkIf cfg.enableZshIntegration shellIntegrationStr;
115  };
116}