From 5848a65266ded7f189b15461ef80317c5d173556 Mon Sep 17 00:00:00 2001 From: vali Date: Wed, 31 Jul 2024 02:09:58 +0200 Subject: [PATCH] working zellij --- hosts/vali/hermit/configuration.nix | 6 +- hosts/vali/temperance/configuration.nix | 7 +- hosts/vali/temperance/programs.nix | 2 + modules/cli/default.nix | 10 +- modules/cli/zellij.nix | 44 +++++++ modules/cli/zellij/default.nix | 47 ++++++++ modules/cli/zellij/layouts/system.kdl | 127 ++++++++++++++++++++ modules/editors/helix.nix | 4 +- modules/options/system/programs/default.nix | 1 + modules/other/xdg.nix | 2 +- modules/styling/stylix.nix | 4 +- 11 files changed, 242 insertions(+), 12 deletions(-) create mode 100644 modules/cli/zellij.nix create mode 100644 modules/cli/zellij/default.nix create mode 100644 modules/cli/zellij/layouts/system.kdl diff --git a/hosts/vali/hermit/configuration.nix b/hosts/vali/hermit/configuration.nix index 7b6a5f7..c81de5c 100644 --- a/hosts/vali/hermit/configuration.nix +++ b/hosts/vali/hermit/configuration.nix @@ -96,10 +96,10 @@ beets.enable = true; }; editors = { - emacs.enable = true; + emacs.enable = false; helix.enable = true; - kakoune.enable = true; - neovim.enable = true; + kakoune.enable = false; + neovim.enable = false; }; services = { pipewire.enable = true; diff --git a/hosts/vali/temperance/configuration.nix b/hosts/vali/temperance/configuration.nix index bf85727..7b23d78 100644 --- a/hosts/vali/temperance/configuration.nix +++ b/hosts/vali/temperance/configuration.nix @@ -30,14 +30,15 @@ system = { programs = { editors = { - emacs.enable = true; - neovim.enable = true; + emacs.enable = false; + neovim.enable = false; helix.enable = true; - kakoune.enable = true; + kakoune.enable = false; }; discord.enable = true; firefox.enable = true; zathura.enable = true; + zellij.enable = true; terminals = { foot.enable = true; kitty.enable = true; diff --git a/hosts/vali/temperance/programs.nix b/hosts/vali/temperance/programs.nix index aa8a35e..14733a0 100644 --- a/hosts/vali/temperance/programs.nix +++ b/hosts/vali/temperance/programs.nix @@ -73,6 +73,7 @@ in { playerctl polkit prismlauncher + pulsemixer python3 qbittorrent r2modman @@ -104,6 +105,7 @@ in { wl-clipboard xdg-utils xournalpp + yazi zapzap zip ]; diff --git a/modules/cli/default.nix b/modules/cli/default.nix index 3a7345d..a0d3469 100644 --- a/modules/cli/default.nix +++ b/modules/cli/default.nix @@ -1 +1,9 @@ -_: {imports = [./fish.nix ./nh.nix ./starship.nix ./beets.nix];} +_: { + imports = [ + ./fish.nix + ./nh.nix + ./starship.nix + ./beets.nix + ./zellij + ]; +} diff --git a/modules/cli/zellij.nix b/modules/cli/zellij.nix new file mode 100644 index 0000000..a43a555 --- /dev/null +++ b/modules/cli/zellij.nix @@ -0,0 +1,44 @@ +{ + config, + lib, + ... +}: let + inherit (config.modules.other.system) username; + cfg = config.modules.system.programs.zellij; + inherit (lib) mkIf; +in { + config = mkIf cfg.enable { + home-manager.users.${username} = { + programs.zellij = { + enable = true; + enableFishIntegration = true; + on_force_close = "quit"; + layout_dir = "${./layouts}"; + settings = { + pane_frames = false; + default_layout = "compact"; + ui = { + pane_frames = { + hide_session_name = true; + rounded.corners = true; + }; + }; + + plugins = { + tab-bar.path = "tab-bar"; + status-bar.path = "status-bar"; + strider.path = "strider"; + compact-bar.path = "compact-bar"; + }; + + keybinds = { + unbind = "Ctrl n"; + # resize = { + # bind = "Ctrl n"; + # }; + }; + }; + }; + }; + }; +} diff --git a/modules/cli/zellij/default.nix b/modules/cli/zellij/default.nix new file mode 100644 index 0000000..ce4e617 --- /dev/null +++ b/modules/cli/zellij/default.nix @@ -0,0 +1,47 @@ +{ + config, + lib, + ... +}: let + inherit (config.modules.other.system) username; + cfg = config.modules.system.programs.zellij; + inherit (lib) mkIf; +in { + config = mkIf cfg.enable { + home-manager.users.${username} = { + programs.zellij = { + enable = true; + + enableFishIntegration = true; + + settings = { + layout_dir = "${./layouts}"; + on_force_close = "quit"; + pane_frames = false; + default_layout = "compact"; + + ui = { + pane_frames = { + hide_session_name = true; + rounded_corners = true; + }; + }; + + plugins = { + tab-bar.path = "tab-bar"; + status-bar.path = "status-bar"; + strider.path = "strider"; + compact-bar.path = "compact-bar"; + }; + + keybinds = { + unbind = "Ctrl n"; + # resize = { + # bind = "Ctrl n"; + # }; + }; + }; + }; + }; + }; +} diff --git a/modules/cli/zellij/layouts/system.kdl b/modules/cli/zellij/layouts/system.kdl new file mode 100644 index 0000000..23a2be9 --- /dev/null +++ b/modules/cli/zellij/layouts/system.kdl @@ -0,0 +1,127 @@ +// this is my custom "system" layout, loosely based on the official +// zellij development layout - it's simplified for desktop use +// and allows me to remain in a single workspace even when I'm +// using a tiling window manager and am constrained to a single +// workspace. It provides default tabs for media, file browsing +// which should be everything that I need, but I may add more +// in the future + +layout { + // define default tab layout + default_tab_template { + // tab bar on the top + pane size=1 borderless=true { + plugin location="zellij:tab-bar" + } + + // child tabs and panes + children + + // status bar on the bottom + pane size=2 borderless=true { + plugin location="zellij:status-bar" + } + } + + // strider tab uses the strider plugin of zellij + // which is similar to neovim's nvimtree + // ...but slower and much less configurable + tab_template name="strider_tab" { + pane size=1 borderless=true { + plugin location="zellij:tab-bar" + } + + // use the strider plugin on the left side of the screen + // to achieve a nvim-tree like layout on the left 15% of + // the terminal window - looks cool but is not flexible + pane split_direction="Vertical" { + pane size="15%" name="Filetree" { + plugin location="zellij:strider" + } + children + } + + pane size=2 borderless=true { + plugin location="zellij:status-bar" + } + } + + // define a template pane for the terminal + // this once again imitates the neovim layout + // by providing a terminal instance on the bottom + // 25% of the screen that enters the z shell when + // zellij starts - the exec duration for zsh matters + // here as it'll repeat for each "tab" that exists + pane_template name="term" { + // horizontal split to place the terminal + // on the bottom half of the screen like the + // toggleterm neovim plugin + pane split_direction="horizontal" { + children + pane command="fish" size="25%" name="Shell" + } + } + + // create a "strider tab" for my system configuration + // which is a tab that utilizes the strider tab template + // that we have defined earlier, provides a file-tree + // view in my system config directory, and opens flake.nix + // with the $EDITOR variable - has focus, is the first tab + strider_tab name="nichts" cwd="~/projects/nichts" focus=true { + term split_direction="vertical" { + // FIXME: edit does not open the file from cwd + // instead opens a buffer named flake.nix in cwd + // which should be the original flake.nix + // but is not + pane edit="./flake.nix" name="Flake" + } + } + + // regular vertical tab that will open btop automatically for + // viewing active processes in a standalone tab + // more utilities can go here if seen necessary + tab name="Processes" split_direction="vertical" { + pane { + // open btop in the home directory + // doesn't really matter where you open it + cwd "$HOME" + command "btop" + } + } + + // the media tab opens musikcube, the TUI music player + // and pulsemixer for volume control across different + // audio devices - this is split horizontally so that + // the mixer covers less space on the screen, at the + // bottom 35% of the active tab + tab name="Media" split_direction="vertical" { + // run musikcube in the Music directory + // the CWD doesn't really matter as musikcube + // is capable of binding to mpd daemon but + // the music directory seemed suitable as + // the working directory for the player + pane split_direction="horizontal" name="Player" { + pane { + cwd "$HOME/Nextcloud/Media/Music" + command "ncmpcpp" + } + } + + // standalone pane for pulsemixer + pane split_direction="horizontal" name="Mixer" { + pane size="35%" { + command "pulsemixer" + } + } + } + + // The last tab is a file browser that opens in the home directory + // so that I may freely browse my files and open them using the XDG + // specs when yazi can handle the file type. + tab name="Files" split_direction="horizontal" name="Files" { + pane { + cwd "$HOME" + command "yazi" + } + } +} diff --git a/modules/editors/helix.nix b/modules/editors/helix.nix index e2b16e3..bab7c6e 100644 --- a/modules/editors/helix.nix +++ b/modules/editors/helix.nix @@ -31,12 +31,12 @@ in { ]; }); settings = { - theme = "catppuccin_mocha"; + # theme = "catppuccin_mocha"; editor = { indent-guides.render = true; lsp.display-inlay-hints = true; line-number = "relative"; - mouse = false; + mouse = true; bufferline = "multiple"; soft-wrap.enable = true; lsp.display-messages = true; diff --git a/modules/options/system/programs/default.nix b/modules/options/system/programs/default.nix index 2a18c33..82e2520 100644 --- a/modules/options/system/programs/default.nix +++ b/modules/options/system/programs/default.nix @@ -14,6 +14,7 @@ in { zathura.enable = mkEnableOption "Zathura pdf viewer"; nextcloud.enable = mkEnableOption "Nextcloud sync client"; firefox.enable = mkEnableOption "Firefox web browser"; + zellij.enable = mkEnableOption "Zellij terminal multiplexer"; terminals = { foot.enable = mkEnableOption "Foot terminal emulator"; diff --git a/modules/other/xdg.nix b/modules/other/xdg.nix index ae5b3bb..4219b89 100644 --- a/modules/other/xdg.nix +++ b/modules/other/xdg.nix @@ -7,7 +7,7 @@ file_manager = "nautilus.desktop"; media_player = "mpv.desktop"; image_viewer = "imv.desktop"; - text_editor = "nvim.desktop"; + text_editor = "helix.desktop"; terminal = "foot.desktop"; in { environment.sessionVariables = {TERMINAL = "${terminal}";}; diff --git a/modules/styling/stylix.nix b/modules/styling/stylix.nix index 490ca9a..1904f03 100644 --- a/modules/styling/stylix.nix +++ b/modules/styling/stylix.nix @@ -14,7 +14,7 @@ in { config = mkIf cfg.enable { stylix = { enable = true; - autoEnable = true; + autoEnable = false; homeManagerIntegration = { followSystem = true; autoImport = true; @@ -77,7 +77,7 @@ in { home-manager.users.${username} = { stylix.targets = { btop.enable = true; - helix.enable = false; + helix.enable = true; dunst.enable = true; firefox.enable = true; foot.enable = true;