2022-12-11 07:34:36 +00:00
|
|
|
# Configurations for shell stuffs.
|
2023-06-05 03:17:13 +00:00
|
|
|
# Should probably be decoupled even more for each feature
|
2022-12-11 07:34:36 +00:00
|
|
|
{
|
2023-06-18 00:46:31 +00:00
|
|
|
config,
|
|
|
|
proj_root,
|
|
|
|
myLib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
cfg = config.base.shells;
|
|
|
|
in {
|
2022-12-11 07:34:36 +00:00
|
|
|
options.base.shells = {
|
|
|
|
enable = myLib.mkOption {
|
|
|
|
type = myLib.types.bool;
|
|
|
|
description = "Enable umbrella shell configuration";
|
|
|
|
default = true;
|
|
|
|
example = false;
|
|
|
|
};
|
|
|
|
# TODO: Support shell-specific init
|
|
|
|
shellInitExtra = myLib.mkOption {
|
|
|
|
type = myLib.types.str;
|
|
|
|
description = "Extra shell init. The syntax should be sh-compliant";
|
|
|
|
default = "";
|
|
|
|
example = ''
|
|
|
|
# X11 support for WSL
|
|
|
|
export DISPLAY=$(ip route list default | awk '{print $3}'):0
|
|
|
|
export LIBGL_ALWAYS_INDIRECT=1
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
shellAliases = myLib.mkOption {
|
|
|
|
type = myLib.types.attrs;
|
|
|
|
description = "Shell command aliases";
|
2023-06-18 00:46:31 +00:00
|
|
|
default = {};
|
2022-12-11 07:34:36 +00:00
|
|
|
example = {
|
|
|
|
nixGL = "nixGLIntel";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
config = myLib.mkIf cfg.enable {
|
|
|
|
# nix: Propagates the environment with packages and vars when enter (children of)
|
|
|
|
# a directory with shell.nix-compatible and .envrc
|
|
|
|
programs.direnv = {
|
|
|
|
enable = true;
|
|
|
|
nix-direnv.enable = true;
|
|
|
|
# nix-direnv.enableFlakes = true; # must remove. this will always be supported.
|
|
|
|
};
|
|
|
|
# z <path> as smarter cd
|
|
|
|
programs.zoxide = {
|
|
|
|
enable = true;
|
|
|
|
enableZshIntegration = true;
|
|
|
|
};
|
|
|
|
programs.tmux = {
|
|
|
|
enable = true;
|
2023-04-02 06:35:11 +00:00
|
|
|
# extraConfigBeforePlugin = builtins.readFile "${proj_root.config.path}/tmux/tmux.conf";
|
2023-06-18 00:46:31 +00:00
|
|
|
plugins = let inherit (pkgs.tmuxPlugins) cpu net-speed; in [cpu net-speed];
|
|
|
|
extraConfig = builtins.readFile "${proj_root.config.path}/tmux/tmux.conf";
|
2022-12-11 07:34:36 +00:00
|
|
|
};
|
2023-05-02 16:28:34 +00:00
|
|
|
xdg.configFile."tmux/tmux.conf".text = myLib.mkOrder 600 ''
|
|
|
|
set -g status-right '#{cpu_bg_color} CPU: #{cpu_icon} #{cpu_percentage} | %a %h-%d %H:%M '
|
|
|
|
'';
|
2023-06-05 03:17:13 +00:00
|
|
|
# Colored ls
|
2022-12-11 07:34:36 +00:00
|
|
|
programs.exa = {
|
|
|
|
enable = true;
|
|
|
|
enableAliases = true;
|
|
|
|
};
|
2023-06-05 03:17:13 +00:00
|
|
|
# Make the shell look beautiful
|
2022-12-11 07:34:36 +00:00
|
|
|
programs.starship = {
|
|
|
|
enable = true;
|
|
|
|
enableZshIntegration = true;
|
2023-06-18 00:46:31 +00:00
|
|
|
settings = let
|
2023-06-16 23:12:54 +00:00
|
|
|
native = builtins.fromTOML (builtins.readFile "${proj_root.config.path}/starship/starship.toml");
|
2023-06-18 00:46:31 +00:00
|
|
|
patch-nix = pkgs.lib.recursiveUpdate native {
|
2023-06-18 09:51:33 +00:00
|
|
|
# WARNING: home-manager fails on here for some reason. Likely not at the
|
2023-06-18 09:06:08 +00:00
|
|
|
# validation phase (type-checking), but at evaluation phaase (stringify)
|
|
|
|
# c.commands = [
|
|
|
|
# ["nix" "run" "nixpkgs#clang" "--" "--version"]
|
|
|
|
# ["nix" "run" "nixpkgs#gcc" "--" "--version"]
|
|
|
|
# ];
|
|
|
|
c.commands = "fuk";
|
2023-06-18 00:46:31 +00:00
|
|
|
};
|
|
|
|
in
|
|
|
|
patch-nix;
|
2022-12-11 07:34:36 +00:00
|
|
|
};
|
2023-06-05 03:17:13 +00:00
|
|
|
# Fuzzy finder. `fzf` for TUI, `fzf -f '<fuzzy query>'` for UNIX piping
|
2022-12-11 07:34:36 +00:00
|
|
|
programs.fzf.enable = true;
|
|
|
|
programs.bash = {
|
|
|
|
enable = true;
|
|
|
|
enableCompletion = true;
|
|
|
|
initExtra = cfg.shellInitExtra or "";
|
|
|
|
};
|
|
|
|
programs.zsh = {
|
|
|
|
enable = true;
|
|
|
|
enableCompletion = true;
|
|
|
|
enableAutosuggestions = true;
|
2023-06-18 00:46:31 +00:00
|
|
|
shellAliases =
|
|
|
|
{
|
|
|
|
nix-rebuild = "sudo nixos-rebuild switch";
|
|
|
|
hm-switch = "home-manager switch --flake";
|
|
|
|
}
|
|
|
|
// (cfg.shellAliases or {});
|
2022-12-11 07:34:36 +00:00
|
|
|
history = {
|
|
|
|
size = 10000;
|
|
|
|
path = "${config.xdg.dataHome}/zsh/history";
|
|
|
|
};
|
|
|
|
oh-my-zsh = {
|
|
|
|
enable = true;
|
2022-12-30 03:19:02 +00:00
|
|
|
plugins = [
|
2023-01-13 06:42:21 +00:00
|
|
|
"git" # git command aliases: https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git#aliases
|
2022-12-30 09:21:59 +00:00
|
|
|
# "sudo" # double-escape to prepend sudo # UPDATE: just use vi-mode lol
|
2022-12-30 03:19:02 +00:00
|
|
|
"command-not-found" # suggests which package to install; does not support nixos (we have solution already)
|
|
|
|
"gitignore" # `gi list` -> `gi java >>.gitignore`
|
2023-01-13 06:42:21 +00:00
|
|
|
"ripgrep" # adds completion for `rg`
|
2023-03-22 23:35:03 +00:00
|
|
|
"rust" # compe for rustc/cargo
|
|
|
|
"poetry" # compe for poetry - Python's cargo
|
2022-12-30 09:21:59 +00:00
|
|
|
# "vi-mode" # edit promps with vi motions :)
|
2022-12-30 03:19:02 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
sessionVariables = {
|
2023-06-05 03:17:13 +00:00
|
|
|
# Vim mode on the terminal
|
|
|
|
|
2022-12-30 09:21:59 +00:00
|
|
|
# VI_MODE_RESET_PROMPT_ON_MODE_CHANGE = true;
|
|
|
|
# VI_MODE_SET_CURSOR = true;
|
|
|
|
# ZVM_VI_ESCAPE_BINDKEY = "";
|
2023-01-13 06:42:21 +00:00
|
|
|
ZVM_READKEY_ENGINE = "$ZVM_READKEY_ENGINE_NEX";
|
|
|
|
ZVM_KEYTIMEOUT = 0.004; # 40ms, or subtly around 25 FPS. I'm a gamer :)
|
|
|
|
ZVM_ESCAPE_KEYTIMEOUT = 0.004; # 40ms, or subtly around 25 FPS. I'm a gamer :)
|
2022-12-11 07:34:36 +00:00
|
|
|
};
|
2023-06-18 00:46:31 +00:00
|
|
|
initExtra =
|
|
|
|
(cfg.shellInitExtra or "")
|
|
|
|
+ ''
|
|
|
|
source ${pkgs.zsh-vi-mode}/share/zsh-vi-mode/zsh-vi-mode.plugin.zsh
|
|
|
|
'';
|
2022-12-11 07:34:36 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|