From bdddabcd522b3040d51f1c0c0a4348c9181f79ee Mon Sep 17 00:00:00 2001 From: imxyy_soope_ Date: Sun, 1 Feb 2026 09:25:51 +0800 Subject: [PATCH] feat: shpool --- modules/cli/all.nix | 3 ++ modules/cli/misc.nix | 20 ------------- modules/cli/shell/starship.nix | 31 +++++++++++++------- modules/cli/shpool.nix | 41 ++++++++++++++++++++++++++ modules/cli/tmux.nix | 53 ++++++++++++++++++++++++++++++++++ modules/cli/vcs/jj.nix | 3 +- 6 files changed, 118 insertions(+), 33 deletions(-) create mode 100644 modules/cli/shpool.nix create mode 100644 modules/cli/tmux.nix diff --git a/modules/cli/all.nix b/modules/cli/all.nix index 41ebfc0..9a0d12c 100644 --- a/modules/cli/all.nix +++ b/modules/cli/all.nix @@ -14,6 +14,9 @@ in monitor.all.enable = true; shell.all.enable = true; vcs.all.enable = true; + + shpool.enable = true; + tmux.enable = true; }; }; } diff --git a/modules/cli/misc.nix b/modules/cli/misc.nix index 36c0724..d2b3f4b 100644 --- a/modules/cli/misc.nix +++ b/modules/cli/misc.nix @@ -75,26 +75,6 @@ in typos # keep-sorted end ]; - programs.tmux = { - enable = true; - extraConfig = '' - set-option -g mouse on - set-option -a terminal-features ",xterm-256color:RGB,focus,clipboard,usstyle" - ''; - plugins = [ - (pkgs.tmuxPlugins.mkTmuxPlugin { - pluginName = "tokyo-night-tmux"; - rtpFilePath = "tokyo-night.tmux"; - version = "legacy"; - src = pkgs.fetchFromGitHub { - owner = "janoamaral"; - repo = "tokyo-night-tmux"; - rev = "16469dfad86846138f594ceec780db27039c06cd"; - hash = "sha256-EKCgYan0WayXnkSb2fDJxookdBLW0XBKi2hf/YISwJE="; - }; - }) - ]; - }; programs.tealdeer = { enable = true; enableAutoUpdates = true; diff --git a/modules/cli/shell/starship.nix b/modules/cli/shell/starship.nix index 5b97c97..4aaf255 100644 --- a/modules/cli/shell/starship.nix +++ b/modules/cli/shell/starship.nix @@ -5,17 +5,26 @@ in { options.my.cli.shell.starship = { enable = lib.mkEnableOption "starship prompt"; - }; - - config = lib.mkIf cfg.enable { - my.hm = { - programs.starship = { - enable = true; - settings = lib.recursiveUpdate (with builtins; fromTOML (readFile ./starship-preset.toml)) { - add_newline = false; - nix_shell.disabled = true; - }; - }; + format = lib.mkOption { + type = with lib.types; listOf singleLineStr; }; }; + + config = lib.mkMerge [ + { + my.cli.shell.starship.format = lib.mkOrder 0 [ "$all" ]; + } + (lib.mkIf cfg.enable { + my.hm = { + programs.starship = { + enable = true; + settings = lib.recursiveUpdate (with builtins; fromTOML (readFile ./starship-preset.toml)) { + add_newline = false; + nix_shell.disabled = true; + format = lib.concatStringsSep "" cfg.format; + }; + }; + }; + }) + ]; } diff --git a/modules/cli/shpool.nix b/modules/cli/shpool.nix new file mode 100644 index 0000000..d916421 --- /dev/null +++ b/modules/cli/shpool.nix @@ -0,0 +1,41 @@ +{ + config, + lib, + ... +}: +let + cfg = config.my.cli.shpool; +in +{ + options.my.cli.shpool = { + enable = lib.mkEnableOption "shpool"; + }; + + config = lib.mkIf cfg.enable { + my.hm = { + services.shpool = { + enable = true; + systemd = true; + settings = { + motd = "never"; + prompt_prefix = ""; + forward_env = [ "PATH" ]; + }; + }; + # https://github.com/starship/starship/discussions/7260 + # programs.starship = { + # settings = { + # custom.shpool = { + # description = "Display current shpool session name"; + # when = ''test -n "$SHPOOL_SESSION_NAME"''; + # command = "echo $SHPOOL_SESSION_NAME"; + # symbol = " "; + # style = "fg:#dea584"; + # format = "[$symbol $output]($style)"; + # }; + # }; + # }; + }; + # my.cli.shell.starship.format = [ "$starship$character" ]; + }; +} diff --git a/modules/cli/tmux.nix b/modules/cli/tmux.nix new file mode 100644 index 0000000..1949364 --- /dev/null +++ b/modules/cli/tmux.nix @@ -0,0 +1,53 @@ +{ + config, + lib, + pkgs, + ... +}: +let + cfg = config.my.cli.tmux; +in +{ + options.my.cli.tmux = { + enable = lib.mkEnableOption "tmux"; + }; + + config = lib.mkIf cfg.enable { + my.hm = { + programs.tmux = { + enable = true; + extraConfig = '' + set-option -g mouse on + set-option -a terminal-features ",xterm-256color:RGB,focus,clipboard,usstyle" + ''; + plugins = [ + (pkgs.tmuxPlugins.mkTmuxPlugin { + pluginName = "tokyo-night-tmux"; + rtpFilePath = "tokyo-night.tmux"; + version = "legacy"; + src = pkgs.fetchFromGitHub { + owner = "janoamaral"; + repo = "tokyo-night-tmux"; + rev = "16469dfad86846138f594ceec780db27039c06cd"; + hash = "sha256-EKCgYan0WayXnkSb2fDJxookdBLW0XBKi2hf/YISwJE="; + }; + }) + ]; + }; + # https://github.com/starship/starship/discussions/7260 + # programs.starship = { + # settings = { + # custom.tmux = { + # description = "Display current tmux session name"; + # when = ''test -n "$TMUX"''; + # command = "tmux display-message -p '#S'"; + # symbol = " "; + # style = "bold green"; + # format = "[$symbol $output]($style)"; + # }; + # }; + # }; + }; + # my.cli.shell.starship.format = [ "$tmux$character" ]; + }; +} diff --git a/modules/cli/vcs/jj.nix b/modules/cli/vcs/jj.nix index 0a93aa5..99fa459 100644 --- a/modules/cli/vcs/jj.nix +++ b/modules/cli/vcs/jj.nix @@ -60,11 +60,10 @@ in programs.starship = { settings = { custom = { + # Borrowed from https://github.com/jj-vcs/jj/wiki/Starship/b18afc53417848f58333b24d446b8e2522b42bd2#alternative-prompt jj = { ignore_timeout = true; description = "The current jj status"; - # when = "${lib.getExe pkgs.jj-starship} detect"; - # command = "${lib.getExe pkgs.jj-starship}"; when = true; command = '' jj log --revisions @ --no-graph --ignore-working-copy --color always --limit 1 --template '