diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 417e7e8c..92cc0991 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -289,6 +289,9 @@ Makefile @thiagokokada /modules/programs/waybar.nix @berbiche /tests/modules/programs/waybar @berbiche +/modules/programs/wezterm.nix @blmhemu +/tests/modules/programs/wezterm @blmhemu + /modules/programs/xmobar.nix @t4ccer /tests/modules/programs/xmobar @t4ccer diff --git a/modules/lib/maintainers.nix b/modules/lib/maintainers.nix index c4507021..c3e7152b 100644 --- a/modules/lib/maintainers.nix +++ b/modules/lib/maintainers.nix @@ -19,6 +19,12 @@ githubId = 56743515; name = "Morgane Austreelis"; }; + blmhemu = { + name = "blmhemu"; + email = "19410501+blmhemu@users.noreply.github.com"; + github = "blmhemu"; + githubId = 19410501; + }; CarlosLoboxyz = { name = "Carlos Lobo"; email = "86011416+CarlosLoboxyz@users.noreply.github.com"; diff --git a/modules/misc/news.nix b/modules/misc/news.nix index fb2c97e0..e54b2dcc 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -639,6 +639,13 @@ in A new module is available: 'programs.hyfetch'. ''; } + + { + time = "2022-08-07T09:07:35+00:00"; + message = '' + A new module is available: 'programs.wezterm'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index d33f90a3..ac2f048e 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -173,6 +173,7 @@ let ./programs/pywal.nix ./programs/watson.nix ./programs/waybar.nix + ./programs/wezterm.nix ./programs/xmobar.nix ./programs/z-lua.nix ./programs/zathura.nix diff --git a/modules/programs/wezterm.nix b/modules/programs/wezterm.nix new file mode 100644 index 00000000..eedd9379 --- /dev/null +++ b/modules/programs/wezterm.nix @@ -0,0 +1,65 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.wezterm; + +in { + 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 + $XDG_CONFIG_HOME/wezterm/wezterm.lua. See + + how to configure. + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ cfg.package ]; + + xdg.configFile."wezterm/wezterm.lua" = { + text = '' + -- Generated by Home Manager. + -- See https://wezfurlong.org/wezterm/ + + -- Add config folder to watchlist for config reloads. + local wezterm = require 'wezterm'; + wezterm.add_to_config_reload_watch_list(wezterm.config_dir) + + ${cfg.extraConfig} + ''; + }; + }; +} diff --git a/tests/default.nix b/tests/default.nix index d004c033..0ee98c30 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -114,6 +114,7 @@ import nmt { ./modules/programs/topgrade ./modules/programs/vscode ./modules/programs/watson + ./modules/programs/wezterm ./modules/programs/zplug ./modules/programs/zsh ./modules/xresources diff --git a/tests/modules/programs/wezterm/default.nix b/tests/modules/programs/wezterm/default.nix new file mode 100644 index 00000000..6a521c9c --- /dev/null +++ b/tests/modules/programs/wezterm/default.nix @@ -0,0 +1,4 @@ +{ + wezterm-example-setting = ./example-setting.nix; + wezterm-empty-setting = ./empty-setting.nix; +} diff --git a/tests/modules/programs/wezterm/empty-setting.nix b/tests/modules/programs/wezterm/empty-setting.nix new file mode 100644 index 00000000..062605aa --- /dev/null +++ b/tests/modules/programs/wezterm/empty-setting.nix @@ -0,0 +1,24 @@ +{ ... }: + +{ + programs.wezterm = { enable = true; }; + + test.stubs.wezterm = { }; + + nmt.script = let + expected = builtins.toFile "wezterm.lua" '' + -- Generated by Home Manager. + -- See https://wezfurlong.org/wezterm/ + + -- Add config folder to watchlist for config reloads. + local wezterm = require 'wezterm'; + wezterm.add_to_config_reload_watch_list(wezterm.config_dir) + + return {} + + ''; + in '' + assertFileExists home-files/.config/wezterm/wezterm.lua + assertFileContent home-files/.config/wezterm/wezterm.lua ${expected} + ''; +} diff --git a/tests/modules/programs/wezterm/example-setting.nix b/tests/modules/programs/wezterm/example-setting.nix new file mode 100644 index 00000000..fc2b08e1 --- /dev/null +++ b/tests/modules/programs/wezterm/example-setting.nix @@ -0,0 +1,47 @@ +{ ... }: + +{ + programs.wezterm = { + enable = true; + extraConfig = '' + return { + 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"}, + } + } + ''; + }; + + test.stubs.wezterm = { }; + + nmt.script = let + expected = builtins.toFile "wezterm.lua" '' + -- Generated by Home Manager. + -- See https://wezfurlong.org/wezterm/ + + -- Add config folder to watchlist for config reloads. + local wezterm = require 'wezterm'; + wezterm.add_to_config_reload_watch_list(wezterm.config_dir) + + return { + 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"}, + } + } + + ''; + in '' + assertFileExists home-files/.config/wezterm/wezterm.lua + assertFileContent home-files/.config/wezterm/wezterm.lua ${expected} + ''; +}