From 63e13b17d04cc26e5f9e143697f54db0a4e8e986 Mon Sep 17 00:00:00 2001 From: Salar Rahmanian Date: Wed, 9 Apr 2025 23:51:21 -0700 Subject: [PATCH] flake update and add wezterm back --- flake.lock | 30 ++++----- programs/default.nix | 1 + programs/wezterm/default.nix | 11 +++ programs/wezterm/wezterm.lua | 127 +++++++++++++++++++++++++++++++++++ 4 files changed, 154 insertions(+), 15 deletions(-) create mode 100644 programs/wezterm/default.nix create mode 100644 programs/wezterm/wezterm.lua diff --git a/flake.lock b/flake.lock index f15b50c..9a49683 100644 --- a/flake.lock +++ b/flake.lock @@ -28,11 +28,11 @@ ] }, "locked": { - "lastModified": 1743869639, - "narHash": "sha256-Xhe3whfRW/Ay05z9m1EZ1/AkbV1yo0tm1CbgjtCi4rQ=", + "lastModified": 1744223888, + "narHash": "sha256-reYpe0J1J+wH34JFs7KKp0G5nP7+XSQ5z0ZLFJcfJr8=", "owner": "nix-community", "repo": "home-manager", - "rev": "d094c6763c6ddb860580e7d3b4201f8f496a6836", + "rev": "79461936709b12e17adb9c91dd02d1c66d577f09", "type": "github" }, "original": { @@ -48,11 +48,11 @@ ] }, "locked": { - "lastModified": 1743496612, - "narHash": "sha256-emPWa5lmKbnyuj8c1mSJUkzJNT+iJoU9GMcXwjp2oVM=", + "lastModified": 1744224272, + "narHash": "sha256-cqePj5nuC7flJWNncaVAFq1YZncU0PSyO0DEqGn+vYc=", "owner": "LnL7", "repo": "nix-darwin", - "rev": "73d59580d01e9b9f957ba749f336a272869c42dd", + "rev": "113883e37d985d26ecb65282766e5719f2539103", "type": "github" }, "original": { @@ -63,11 +63,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1743689281, - "narHash": "sha256-y7Hg5lwWhEOgflEHRfzSH96BOt26LaYfrYWzZ+VoVdg=", + "lastModified": 1744157173, + "narHash": "sha256-bWSjxDwq7iVePrhmA7tY2dyMWHuNJo8knkO4y+q4ZkY=", "owner": "nixos", "repo": "nixpkgs", - "rev": "2bfc080955153be0be56724be6fa5477b4eefabb", + "rev": "6a39c6e495eefabc935d8ddf66aa45d85b85fa3f", "type": "github" }, "original": { @@ -79,11 +79,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1743583204, - "narHash": "sha256-F7n4+KOIfWrwoQjXrL2wD9RhFYLs2/GGe/MQY1sSdlE=", + "lastModified": 1744098102, + "narHash": "sha256-tzCdyIJj9AjysC3OuKA+tMD/kDEDAF9mICPDU7ix0JA=", "owner": "nixos", "repo": "nixpkgs", - "rev": "2c8d3f48d33929642c1c12cd243df4cc7d2ce434", + "rev": "c8cd81426f45942bb2906d5ed2fe21d2f19d95b7", "type": "github" }, "original": { @@ -100,11 +100,11 @@ "treefmt-nix": "treefmt-nix" }, "locked": { - "lastModified": 1743892397, - "narHash": "sha256-KYcVP8nU4E8xtk0IqIuSP46wzArcWZ+7Mf/BY6aZxU8=", + "lastModified": 1744267403, + "narHash": "sha256-tPzYG/n1PP6Bp4MeJfyp9Ng/bQc4vltIBknBBkwLK3I=", "owner": "nix-community", "repo": "nur", - "rev": "b68d8ff58b2a40a595c6985588ad98cba415eb40", + "rev": "cb85fb3dd03d43c2db28dadb43d9bb54857b1150", "type": "github" }, "original": { diff --git a/programs/default.nix b/programs/default.nix index 119bbd3..4ab53ad 100644 --- a/programs/default.nix +++ b/programs/default.nix @@ -5,6 +5,7 @@ ./git ./jujutsu ./kitty + ./wezterm ./vscode ./zed ] diff --git a/programs/wezterm/default.nix b/programs/wezterm/default.nix new file mode 100644 index 0000000..c63a016 --- /dev/null +++ b/programs/wezterm/default.nix @@ -0,0 +1,11 @@ +{ ... }: + +let + weztermConfig = builtins.readFile ./wezterm.lua; +in +{ + programs.wezterm = { + enable = true; + extraConfig = weztermConfig; + }; +} diff --git a/programs/wezterm/wezterm.lua b/programs/wezterm/wezterm.lua new file mode 100644 index 0000000..c15ee4a --- /dev/null +++ b/programs/wezterm/wezterm.lua @@ -0,0 +1,127 @@ +local wezterm = require 'wezterm' +local mux = wezterm.mux +local act = wezterm.action + +wezterm.on('update-right-status', function(window, pane) + window:set_right_status(window:active_workspace()) +end) + +wezterm.on('gui-startup', function(cmd) + local tab, pane, window = mux.spawn_window(cmd or {}) + window:gui_window():maximize() + pane:split { size = 0.2 } +end) + +return { + adjust_window_size_when_changing_font_size = false, + check_for_updates = false, + color_scheme = 'Tango (terminal.sexy)', + default_gui_startup_args = { 'connect', 'unix' }, + font = wezterm.font_with_fallback { 'JetBrains Mono', 'Noto Color Emoji' }, + font_size = 12.0, + dpi = 144, + scrollback_lines = 50000, + initial_cols = 400, + initial_rows = 80, + leader = { key = 'b', mods = 'SUPER', timeout_milliseconds = 1000 }, + default_prog = { '/etc/profiles/per-user/salar/bin/fish' }, + window_decorations = 'RESIZE', + ssh_domains = { + { + name = 'hcloud1', + remote_address = 'hcloud1.softinio.net', + username = 'salar', + remote_wezterm_path = '/run/current-system/sw/bin/wezterm', + }, + }, + unix_domains = { + { + name = 'unix', + proxy_command = { 'nc', '-U', '/Users/salar/.local/share/wezterm/sock' }, + }, + }, + keys = { + { key = '-', mods = 'LEADER', action = wezterm.action { SplitVertical = { domain = 'CurrentPaneDomain' } } }, + { key = "'", mods = 'LEADER', action = wezterm.action { SplitHorizontal = { domain = 'CurrentPaneDomain' } } }, + { key = 'k', mods = 'SUPER', action = act.TogglePaneZoomState }, + { key = 'h', mods = 'LEADER', action = wezterm.action { ActivatePaneDirection = 'Left' } }, + { key = 'j', mods = 'LEADER', action = wezterm.action { ActivatePaneDirection = 'Down' } }, + { key = 'k', mods = 'LEADER', action = wezterm.action { ActivatePaneDirection = 'Up' } }, + { key = 'l', mods = 'LEADER', action = wezterm.action { ActivatePaneDirection = 'Right' } }, + { key = 'H', mods = 'LEADER|SHIFT', action = wezterm.action { AdjustPaneSize = { 'Left', 5 } } }, + { key = 'J', mods = 'LEADER|SHIFT', action = wezterm.action { AdjustPaneSize = { 'Down', 5 } } }, + { key = 'K', mods = 'LEADER|SHIFT', action = wezterm.action { AdjustPaneSize = { 'Up', 5 } } }, + { key = 'L', mods = 'LEADER|SHIFT', action = wezterm.action { AdjustPaneSize = { 'Right', 5 } } }, + { key = '1', mods = 'LEADER', action = wezterm.action { ActivateTab = 0 } }, + { key = '2', mods = 'LEADER', action = wezterm.action { ActivateTab = 1 } }, + { key = '3', mods = 'LEADER', action = wezterm.action { ActivateTab = 2 } }, + { key = '4', mods = 'LEADER', action = wezterm.action { ActivateTab = 3 } }, + { key = '5', mods = 'LEADER', action = wezterm.action { ActivateTab = 4 } }, + { key = '6', mods = 'LEADER', action = wezterm.action { ActivateTab = 5 } }, + { key = '7', mods = 'LEADER', action = wezterm.action { ActivateTab = 6 } }, + { key = '8', mods = 'LEADER', action = wezterm.action { ActivateTab = 7 } }, + { key = '9', mods = 'LEADER', action = wezterm.action { ActivateTab = 8 } }, + { key = '&', mods = 'LEADER', action = wezterm.action { CloseCurrentTab = { confirm = true } } }, + { key = 'x', mods = 'LEADER', action = wezterm.action { CloseCurrentPane = { confirm = true } } }, + { key = 'Enter', mods = 'ALT', action = act.DisableDefaultAssignment }, + { key = 'c', mods = 'SUPER', action = act.CopyTo 'Clipboard' }, + { key = 'v', mods = 'SUPER', action = act.PasteFrom 'Clipboard' }, + { key = 'n', mods = 'SUPER', action = act.SpawnWindow }, + { key = 't', mods = 'SUPER', action = act.SpawnTab 'CurrentPaneDomain' }, + { key = 'h', mods = 'SUPER', action = act { SpawnCommandInNewTab = { cwd = wezterm.home_dir } } }, + { key = 'q', mods = 'SUPER', action = act.QuitApplication }, + { key = 'i', mods = 'CTRL|SHIFT', action = act.SwitchToWorkspace }, + { + key = '8', + mods = 'ALT', + action = wezterm.action_callback(function(window, pane) + -- Here you can dynamically construct a longer list if needed + + local home = wezterm.home_dir + local workspaces = { + { id = home, label = 'Home' }, + { id = home .. '/Projects', label = 'My Projects' }, + { id = home .. '/OpenSource', label = 'Open Source Projects' }, + { id = home .. '/.config/nixpkgs', label = 'Nix Config' }, + { id = home .. '/Projects/scalanews', label = 'Scala News' }, + } + + window:perform_action( + act.InputSelector { + action = wezterm.action_callback(function(inner_window, inner_pane, id, label) + if not id and not label then + wezterm.log_info 'cancelled' + else + wezterm.log_info('id = ' .. id) + wezterm.log_info('label = ' .. label) + inner_window:perform_action( + act.SwitchToWorkspace { + name = label, + spawn = { + label = 'Workspace: ' .. label, + cwd = id, + }, + }, + inner_pane + ) + end + end), + title = 'Choose Workspace', + choices = workspaces, + fuzzy = true, + fuzzy_description = 'Fuzzy find and/or make a workspace', + }, + pane + ) + end), + }, + { + key = '9', + mods = 'ALT', + action = act.ShowLauncherArgs { + flags = 'FUZZY|WORKSPACES', + }, + }, + { key = 'Tab', mods = 'CTRL', action = wezterm.action.DisableDefaultAssignment }, + }, +}