From d9e03b7f8c67890b920c92d8154dd9b60bb1242f Mon Sep 17 00:00:00 2001 From: Hemanth Bollamreddi Date: Fri, 8 Apr 2022 12:18:27 +0530 Subject: [PATCH] wezterm: add module --- .github/CODEOWNERS | 3 + modules/lib/maintainers.nix | 6 ++ modules/misc/news.nix | 7 ++ modules/modules.nix | 1 + modules/programs/wezterm.nix | 65 +++++++++++++++++++ tests/default.nix | 1 + tests/modules/programs/wezterm/default.nix | 4 ++ .../programs/wezterm/empty-setting.nix | 24 +++++++ .../programs/wezterm/example-setting.nix | 47 ++++++++++++++ 9 files changed, 158 insertions(+) create mode 100644 modules/programs/wezterm.nix create mode 100644 tests/modules/programs/wezterm/default.nix create mode 100644 tests/modules/programs/wezterm/empty-setting.nix create mode 100644 tests/modules/programs/wezterm/example-setting.nix diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 417e7e8ca..92cc0991e 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 c4507021c..c3e7152b4 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 fb2c97e03..e54b2dccc 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 d33f90a3f..ac2f048e0 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 000000000..eedd93797 --- /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 d004c0331..0ee98c30e 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 000000000..6a521c9c4 --- /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 000000000..062605aaa --- /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 000000000..fc2b08e1f --- /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} + ''; +}