From 6efda6a816ac316130cfb7c146b1a61d944057af Mon Sep 17 00:00:00 2001 From: Jonni Liljamo Date: Wed, 25 Sep 2024 19:31:21 +0300 Subject: [PATCH] feat: make zellij usable --- flake.lock | 95 ++++++++++++++++++++++++++++++++++++++++++- flake.nix | 6 +++ roles/zellij.nix | 104 +++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 197 insertions(+), 8 deletions(-) diff --git a/flake.lock b/flake.lock index 3600cdf..cf82974 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,20 @@ { "nodes": { + "crane": { + "locked": { + "lastModified": 1725409566, + "narHash": "sha256-PrtLmqhM6UtJP7v7IGyzjBFhbG4eOAHT6LPYOFmYfbk=", + "owner": "ipetkov", + "repo": "crane", + "rev": "7e4586bad4e3f8f97a9271def747cf58c4b68f3c", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, "devshell": { "inputs": { "flake-utils": "flake-utils", @@ -165,6 +180,24 @@ "type": "github" } }, + "flake-utils_3": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "git-hooks": { "inputs": { "flake-compat": "flake-compat", @@ -549,7 +582,29 @@ "nixpkgs-unstable": "nixpkgs-unstable", "nvim-flake": "nvim-flake", "sops-nix": "sops-nix", - "tamma": "tamma" + "tamma": "tamma", + "zjstatus": "zjstatus" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "zjstatus", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1726453838, + "narHash": "sha256-pupsow4L79SBfNwT6vh/5RAbVZuhngIA0RTCZksXmZY=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "ca2e79cd22625d214b8437c2c4080ce79bd9f7d2", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" } }, "sops-nix": { @@ -605,6 +660,21 @@ "type": "github" } }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "tamma": { "inputs": { "flake-utils": "flake-utils_2", @@ -647,6 +717,29 @@ "repo": "treefmt-nix", "type": "github" } + }, + "zjstatus": { + "inputs": { + "crane": "crane", + "flake-utils": "flake-utils_3", + "nixpkgs": [ + "nixpkgs-unstable" + ], + "rust-overlay": "rust-overlay" + }, + "locked": { + "lastModified": 1726515093, + "narHash": "sha256-Y2OHV3QfLPQj3Q4+TmrMeRXthwigU/YSBv2g8y8GWWU=", + "owner": "dj95", + "repo": "zjstatus", + "rev": "d1c662c1052adec6f14f3ee8a51cecebe4a29ffa", + "type": "github" + }, + "original": { + "owner": "dj95", + "repo": "zjstatus", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 74a7f1c..45f4027 100644 --- a/flake.nix +++ b/flake.nix @@ -29,6 +29,12 @@ inputs.nixpkgs.follows = "nixpkgs-unstable"; }; + # Packages + zjstatus = { + url = "github:dj95/zjstatus"; + inputs.nixpkgs.follows = "nixpkgs-unstable"; + }; + # Own flakes tamma.url = "git+https://git.src.quest/~liljamo/tamma?ref=refs/tags/0.1.2"; nvim-flake = { diff --git a/roles/zellij.nix b/roles/zellij.nix index c371ce1..accf199 100644 --- a/roles/zellij.nix +++ b/roles/zellij.nix @@ -1,23 +1,113 @@ { config, + inputs, lib, + pkgs, ... }: let cfg = config.roles.zellij; + + # hard light + # https://github.com/sainnhe/everforest/blob/master/palette.md#light + # https://github.com/sainnhe/everforest/blob/e5b9e2fb676a9ded3e86ae51924f7962fa4fb0ac/autoload/everforest.vim#L51 + everforest = { + bg0 = "#FFF9E8"; + bg1 = "#F8F5E4"; + bg2 = "#F2EFDF"; + bg3 = "#EDEADA"; + bg4 = "#E8E5D5"; + bg5 = "#BEC5B2"; + fg = { + default = "#5C6A72"; + accent = { + cyan = "#35A77C"; + green = "#8DA101"; + }; + grey0 = "#7A8478"; + grey1 = "#859289"; + grey2 = "#9DA9A0"; + statusline = { + green = "#93B259"; + grey = "#708089"; + red = "#E66868"; + }; + }; + }; + + zjstatus = '' + plugin location="file:${inputs.zjstatus.packages.${pkgs.system}.default}/bin/zjstatus.wasm" { + format_left "{mode}" + format_center "{tabs}" + + mode_locked "#[fg=${everforest.bg0},bg=${everforest.fg.statusline.red},bold] {name} " + mode_normal "#[fg=${everforest.bg0},bg=${everforest.fg.statusline.green},bold] {name} " + mode_tab "#[fg=${everforest.bg0},bg=${everforest.fg.accent.cyan},bold] {name} " + + tab_active "#[fg=${everforest.bg0},bg=${everforest.fg.statusline.green}] {name} " + tab_normal "#[fg=${everforest.fg.default},bg=${everforest.bg3}] {name} " + } + ''; in { options.roles.zellij = { enable = lib.mkEnableOption "enable zellij"; }; config = lib.mkIf cfg.enable { - hm.programs.zellij = { - enable = true; - settings = { - simplified_ui = true; - pane_frames = false; - default_layout = "compact"; - ui.pane_frames.hide_session_name = true; + hm = { + programs.zellij = { + enable = true; + settings = { + default_shell = "elvish"; + simplified_ui = true; + pane_frames = false; + default_layout = "default"; + ui.pane_frames.hide_session_name = true; + }; }; + + home.file.".config/zellij/layouts/default.kdl".text = '' + layout { + default_tab_template { + children + pane size=1 { + ${zjstatus} + } + } + + tab { + pane + } + } + ''; + + home.file.".config/zellij/layouts/dev.kdl".text = '' + layout { + default_tab_template { + children + pane size=1 { + ${zjstatus} + } + } + + tab name="nvim" focus=true { + pane + } + + tab name="shell" { + pane + } + } + + keybinds { + locked { + bind "Insert" { GoToTab 2; SwitchToMode "Normal"; } + } + + shared_except "locked" { + bind "Insert" { GoToTab 1; SwitchToMode "Locked"; } + } + } + ''; }; }; } -- 2.44.1