dotfiles/nix/repo/home-profiles/shells.nix

131 lines
3.9 KiB
Nix
Raw Permalink Normal View History

{
2023-06-18 00:46:31 +00:00
inputs,
cell,
namespace,
}: {
config,
lib,
pkgs,
...
}: let
cfg = config."${namespace}".shells;
in {
options."${namespace}".shells = {
enable = lib.mkOption {
type = lib.types.bool;
description = "Enable umbrella shell configuration";
default = true;
example = false;
};
shellInitExtra = lib.mkOption {
type = lib.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 = lib.mkOption {
type = lib.types.attrs;
description = "Shell command aliases";
2023-06-18 00:46:31 +00:00
default = {};
example = {
nixGL = "nixGLIntel";
};
};
};
config = lib.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-06-18 00:46:31 +00:00
plugins = let inherit (pkgs.tmuxPlugins) cpu net-speed; in [cpu net-speed];
extraConfig = builtins.readFile "${inputs.self}/native_configs/tmux/tmux.conf";
};
xdg.configFile."tmux/tmux.conf".text = lib.mkOrder 600 ''
set -g status-right '#{cpu_bg_color} CPU: #{cpu_icon} #{cpu_percentage} | %a %h-%d %H:%M '
'';
# Colored ls
2023-09-24 08:46:32 +00:00
programs.eza = {
enable = true;
enableAliases = true;
};
# Make the shell look beautiful
programs.starship = {
enable = true;
enableZshIntegration = true;
2023-06-18 00:46:31 +00:00
settings = let
native = builtins.fromTOML (builtins.readFile "${inputs.self}/native_configs/starship/starship.toml");
patch-nix = pkgs.lib.recursiveUpdate native {
2023-06-18 09:06:08 +00:00
c.disabled = true;
2023-06-18 00:46:31 +00:00
};
in
patch-nix;
};
# Fuzzy finder. `fzf` for TUI, `fzf -f '<fuzzy query>'` for UNIX piping
programs.fzf.enable = true;
programs.bash = {
enable = true;
enableCompletion = true;
initExtra = cfg.shellInitExtra or "";
shellAliases =
{ }
// (cfg.shellAliases 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 {});
history = {
size = 10000;
path = "${config.xdg.dataHome}/zsh/history";
};
oh-my-zsh = {
enable = true;
plugins = [
"git" # git command aliases: https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git#aliases
2023-07-25 20:26:08 +00:00
# DEPRECATION: potentially smelly plugin with nix
# "command-not-found" # suggests which package to install; does not support nixos (we have solution already)
2023-10-21 21:13:19 +00:00
# "gitignore", allows gi CLI interaction
"ripgrep" # adds completion for ripgrep
"rust"
"poetry"
];
};
sessionVariables = {
# Vim mode on the terminal
# VI_MODE_RESET_PROMPT_ON_MODE_CHANGE = true;
# VI_MODE_SET_CURSOR = true;
# ZVM_VI_ESCAPE_BINDKEY = "";
ZVM_READKEY_ENGINE = "$ZVM_READKEY_ENGINE_NEX";
2023-07-25 20:26:08 +00:00
# lowest possible: 0.004s
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 :)
};
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
'';
};
};
}