From bd2df72ebc4b1ad643ab32ea8fc823f4e4b4e5cc Mon Sep 17 00:00:00 2001 From: reo101 Date: Tue, 21 Feb 2023 23:31:38 +0200 Subject: [PATCH] feat(wezterm): add module for `wezterm` Enable it for `homix` --- flake.lock | 48 +++---- .../nixos/x86_64-linux/homix/configs/river | 7 +- .../x86_64-linux/homix/configuration.nix | 3 + .../nixos/x86_64-linux/homix/home/reo101.nix | 13 +- modules/home-manager/default.nix | 1 + .../home-manager/reo101-wezterm/default.nix | 47 +++++++ .../home-manager/reo101-wezterm/wezterm.lua | 128 ++++++++++++++++++ 7 files changed, 217 insertions(+), 30 deletions(-) create mode 100644 modules/home-manager/reo101-wezterm/default.nix create mode 100644 modules/home-manager/reo101-wezterm/wezterm.lua diff --git a/flake.lock b/flake.lock index 0e0ca87..03abbd0 100644 --- a/flake.lock +++ b/flake.lock @@ -41,11 +41,11 @@ "diffz": { "flake": false, "locked": { - "lastModified": 1676154556, - "narHash": "sha256-foiZMt5GBbbLEZPPK/qgkjQ6FCj2rLPniaF8rC5Z56w=", + "lastModified": 1676881125, + "narHash": "sha256-iCXoJp+89GhdFO9roE208mhqURTuMX8zKiEEpvMH2do=", "owner": "ziglibs", "repo": "diffz", - "rev": "f25b31c4f8d06bc134018133a2d57b6dcbb6941e", + "rev": "efc91679b000a2d7f86fb40930f0a95a0d349bff", "type": "github" }, "original": { @@ -201,11 +201,11 @@ }, "hardware": { "locked": { - "lastModified": 1675933606, - "narHash": "sha256-y427VhPQHOKkYvkc9MMsL/2R7M11rQxzsRdRLM3htx8=", + "lastModified": 1676924492, + "narHash": "sha256-78278eyP55JRFe7UCpmFwdkrTY6H2arzTpVeteWo8kM=", "owner": "nixos", "repo": "nixos-hardware", - "rev": "44ae00e02e8036a66c08f4decdece7e3bbbefee2", + "rev": "d24ea777c57b69c6b143cf11d83184ef71b0dbbf", "type": "github" }, "original": { @@ -222,11 +222,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1674440933, - "narHash": "sha256-CASRcD/rK3fn5vUCti3jzry7zi0GsqRsBohNq9wPgLs=", + "lastModified": 1676257154, + "narHash": "sha256-eW3jymNLpdxS5fkp9NWKyNtgL0Gqtgg1vCTofKXDF1g=", "owner": "nix-community", "repo": "home-manager", - "rev": "65c47ced082e3353113614f77b1bc18822dc731f", + "rev": "2cb27c79117a2a75ff3416c3199a2dc57af6a527", "type": "github" }, "original": { @@ -262,11 +262,11 @@ }, "locked": { "dir": "contrib", - "lastModified": 1676447500, - "narHash": "sha256-ZwNSq45LcUMfGToWXqwHYsgPeAcqUtmFoQb+vHzr0kQ=", + "lastModified": 1676961797, + "narHash": "sha256-2iFgeZt4U6BGFFVI6T8NOUZoL5WBObuq5HORD75Sbc0=", "owner": "neovim", "repo": "neovim", - "rev": "8307ed3a194d0c0420feb0b3e5c2f6919095415f", + "rev": "f0ee548137263a67e3d163b674f48e6e004210fb", "type": "github" }, "original": { @@ -283,11 +283,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1676448935, - "narHash": "sha256-S3vVH9R6B5d6ypy/nH+QLmSmbixRsiiQCOgQo+sWAWo=", + "lastModified": 1676967323, + "narHash": "sha256-O1MYNghLLIsQAEw5zCTzigIpjliM8mQzetge4nIeY3U=", "owner": "nix-community", "repo": "neovim-nightly-overlay", - "rev": "cc3a0896253491f47a11db5d959206c541b1b443", + "rev": "16013225fd352a7046a4e24e94b3e68331ea815c", "type": "github" }, "original": { @@ -435,11 +435,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1676300157, - "narHash": "sha256-1HjRzfp6LOLfcj/HJHdVKWAkX9QRAouoh6AjzJiIerU=", + "lastModified": 1676885936, + "narHash": "sha256-ZRKb6zBfTvdCOXI7nGC1L9UWSU5ay2ltxg+f5UIzBOU=", "owner": "nixos", "repo": "nixpkgs", - "rev": "545c7a31e5dedea4a6d372712a18e00ce097d462", + "rev": "b69883faca9542d135fa6bab7928ff1b233c167f", "type": "github" }, "original": { @@ -588,11 +588,11 @@ ] }, "locked": { - "lastModified": 1676462917, - "narHash": "sha256-J7PejnvGs3bcKIkYziFnvi3GaqI1/9jsI0RxLlEupUo=", + "lastModified": 1676999840, + "narHash": "sha256-hOctK9Skbpdy1plgZlWzj6EoVQJFwpG1JRrr0F+9l34=", "owner": "mitchellh", "repo": "zig-overlay", - "rev": "e4679c0cc53b68fa68c2b56f7103efef9a885208", + "rev": "1b0d9c8d127616d40abb11f663924293b8e6dbfd", "type": "github" }, "original": { @@ -637,11 +637,11 @@ "zig-overlay": "zig-overlay_2" }, "locked": { - "lastModified": 1676362045, - "narHash": "sha256-rzmbNSLgBju5c7zag2BNQ3eWKsMB15AX45D7hcPj5mo=", + "lastModified": 1676929205, + "narHash": "sha256-gVmxoXi2WJsrIoONXp0CHPbib6mh1yfP8FoBgVOF0zQ=", "owner": "zigtools", "repo": "zls", - "rev": "2071db440d6ec3ec4e76e82473db23ea49449c73", + "rev": "b635317e2a426074fd28fbf954293efb4e124192", "type": "github" }, "original": { diff --git a/machines/nixos/x86_64-linux/homix/configs/river b/machines/nixos/x86_64-linux/homix/configs/river index 54e6f34..10382aa 100644 --- a/machines/nixos/x86_64-linux/homix/configs/river +++ b/machines/nixos/x86_64-linux/homix/configs/river @@ -1,7 +1,10 @@ #!/usr/bin/env sh -# Super+Return to start an instance of foot (https://codeberg.org/dnkl/foot) -riverctl map normal Super Return spawn foot +# # Super+Return to start an instance of foot (https://codeberg.org/dnkl/foot) +# riverctl map normal Super Return spawn foot + +# Super+Return to start an instance of wezterm +riverctl map normal Super Return spawn wezterm # Super+Q to close the focused view riverctl map normal Super Q close diff --git a/machines/nixos/x86_64-linux/homix/configuration.nix b/machines/nixos/x86_64-linux/homix/configuration.nix index 8b9c14e..19ae443 100644 --- a/machines/nixos/x86_64-linux/homix/configuration.nix +++ b/machines/nixos/x86_64-linux/homix/configuration.nix @@ -98,6 +98,9 @@ }; }; + ### Fonts + fonts.fontconfig.enable = true; + ### NVIDIA services.xserver = { videoDrivers = [ "nvidia" ]; diff --git a/machines/nixos/x86_64-linux/homix/home/reo101.nix b/machines/nixos/x86_64-linux/homix/home/reo101.nix index fb1ef20..c59d813 100644 --- a/machines/nixos/x86_64-linux/homix/home/reo101.nix +++ b/machines/nixos/x86_64-linux/homix/home/reo101.nix @@ -89,10 +89,15 @@ userEmail = "pavel.atanasov2001@gmail.com"; }; - reo101.shell = { - enable = true; - direnv = true; - zoxide = true; + reo101 = { + shell = { + enable = true; + direnv = true; + zoxide = true; + }; + wezterm = { + enable = true; + }; }; systemd.user.services."swww" = { diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix index ab1798f..90d14de 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -5,4 +5,5 @@ # List your module files here # my-module = import ./my-module.nix; reo101-shell = import ./reo101-shell.nix; + reo101-wezterm = import ./reo101-wezterm; } diff --git a/modules/home-manager/reo101-wezterm/default.nix b/modules/home-manager/reo101-wezterm/default.nix new file mode 100644 index 0000000..6d9d25e --- /dev/null +++ b/modules/home-manager/reo101-wezterm/default.nix @@ -0,0 +1,47 @@ +{ lib, pkgs, config, ... }: + +with lib; +let + cfg = config.reo101.wezterm; +in +{ + imports = + [ + ]; + + options = + { + reo101.wezterm = { + enable = mkEnableOption "reo101 wezterm setup"; + extraConfig = mkOption { + type = types.str; + description = "Extra zsh config"; + default = '' + ''; + }; + }; + }; + + config = + mkIf cfg.enable { + home.packages = with pkgs; + builtins.concatLists [ + [ + wezterm + (nerdfonts.override { fonts = [ "FiraCode" ]; }) + ] + ]; + + programs.wezterm = { + enable = true; + extraConfig = builtins.concatStringsSep "\n" [ + (builtins.readFile ./wezterm.lua) + cfg.extraConfig + ]; + }; + }; + + meta = { + maintainers = with lib.maintainers; [ reo101 ]; + }; +} diff --git a/modules/home-manager/reo101-wezterm/wezterm.lua b/modules/home-manager/reo101-wezterm/wezterm.lua new file mode 100644 index 0000000..30f51be --- /dev/null +++ b/modules/home-manager/reo101-wezterm/wezterm.lua @@ -0,0 +1,128 @@ +local M = {} + +local wezterm = require("wezterm") + +---------- +-- Font -- +---------- +M.font = wezterm.font("FiraCode Nerd Font Mono") + +------------------ +-- Font options -- +------------------ +M.harfbuzz_features = { + "liga", + "cv02", + "cv19", + "cv25", + "cv26", + "cv28", + "cv30", + "cv32", + "ss02", + "ss03", + "ss05", + "ss07", + "ss09", + "zero", +} + +-------------------- +-- Font rendering -- +-------------------- +M.freetype_render_target = "Light" + +------------------ +-- Cursor style -- +------------------ +-- M.default_cursor_style = "BlinkingBar" + +-------------------- +-- Window options -- +-------------------- +-- M.window_background_opacity = 0.2 +M.text_background_opacity = 1.0 +-- M.window_background_image = "/home/reo101/.local/share/bg/ide_bg.jpeg" +M.window_decorations = "NONE" +M.window_close_confirmation = "NeverPrompt" +M.use_resize_increments = false +M.enable_scroll_bar = false +M.adjust_window_size_when_changing_font_size = false +M.window_padding = { + left = 0, + right = 0, + top = 0, + bottom = 0, +} + +------------- +-- Tab bar -- +------------- +M.enable_tab_bar = false + +-------------- +-- Keybinds -- +-------------- +local function keybind(mods, key, action) + if type(action) == "table" then + action = wezterm.action(action) + end + + return { + mods = mods, + key = key, + action = action, + } +end + +M.disable_default_key_bindings = true +M.keys = { + --------------- + -- Clipboard -- + --------------- + keybind("ALT", "c", { CopyTo = "Clipboard" }), + keybind("ALT", "v", { PasteFrom = "Clipboard" }), + + --------------- + -- Font size -- + --------------- + keybind("ALT|SHIFT", "UpArrow", "IncreaseFontSize"), + keybind("ALT|SHIFT", "DownArrow", "DecreaseFontSize"), + + ------------ + -- Scroll -- + ------------ + keybind("ALT", "u", { ScrollByPage = -1 }), + keybind("ALT", "d", { ScrollByPage = 1 }), + + ------------ + -- Reload -- + ------------ + keybind("CTRL|SHIFT", "r", "ReloadConfiguration"), +} + +----------- +-- Links -- +----------- +M.hyperlink_rules = { + -- Linkify things that look like URLs + -- This is actually the default if you don't specify any hyperlink_rules + { + regex = "\\b\\w+://(?:[\\w.-]+)\\.[a-z]{2,15}\\S*\\b", + format = "$0", + }, + + -- linkify email addresses + { + regex = "\\b\\w+@[\\w-]+(\\.[\\w-]+)+\\b", + format = "mailto:$0", + }, + + -- file:// URI + { + regex = "\\bfile://\\S*\\b", + format = "$0", + }, +} + +return M