320 lines
10 KiB
Nix
320 lines
10 KiB
Nix
# Shell configuration module
|
|
#
|
|
# This module configures the shell environment including:
|
|
# - Zsh with Home Manager's programs.zsh
|
|
# - Starship prompt
|
|
# - Atuin for shell history
|
|
# - Direnv for directory-specific environments
|
|
# - Zoxide for smart directory navigation
|
|
# - Shell aliases from the chezmoi configuration
|
|
# - Environment variables
|
|
{
|
|
config,
|
|
pkgs,
|
|
lib,
|
|
...
|
|
}:
|
|
{
|
|
# ==========================================================================
|
|
# Zsh Configuration
|
|
# ==========================================================================
|
|
programs.zsh = {
|
|
enable = true;
|
|
|
|
# Enable zsh completions
|
|
enableCompletion = true;
|
|
|
|
# Enable syntax highlighting
|
|
syntaxHighlighting.enable = true;
|
|
|
|
# Enable autosuggestions
|
|
autosuggestion.enable = true;
|
|
|
|
# History settings
|
|
history = {
|
|
size = 50000;
|
|
save = 50000;
|
|
ignoreDups = true;
|
|
ignoreAllDups = true;
|
|
ignoreSpace = true;
|
|
share = true;
|
|
};
|
|
|
|
plugins = [
|
|
{
|
|
name = "fast-syntax-highlighting";
|
|
src = "${pkgs.zsh-fast-syntax-highlighting}/share/zsh/site-functions";
|
|
}
|
|
];
|
|
|
|
# Session variables (migrated from dot_zshrc and 01-env.sh)
|
|
sessionVariables = {
|
|
# XDG runtime directory
|
|
XDG_RUNTIME_DIR = "\${XDG_RUNTIME_DIR:-$HOME/.cache}";
|
|
|
|
# Locale
|
|
LANG = "en_US.UTF-8";
|
|
|
|
# Temporary directory
|
|
TMPDIR = "\${TMPDIR:-/tmp}";
|
|
|
|
# Editor (from 01-nvim.sh)
|
|
EDITOR = "nvim";
|
|
|
|
# GPG TTY for SSH sessions
|
|
GPG_TTY = "$(tty)";
|
|
|
|
# FZF Catppuccin color scheme (from dot_zshrc)
|
|
FZF_DEFAULT_OPTS = lib.concatStringsSep " " [
|
|
"--color=bg+:#313244,bg:#1e1e2e,spinner:#f5e0dc,hl:#f38ba8"
|
|
"--color=fg:#cdd6f4,header:#f38ba8,info:#cba6f7,pointer:#f5e0dc"
|
|
"--color=marker:#f5e0dc,fg+:#cdd6f4,prompt:#cba6f7,hl+:#f38ba8"
|
|
];
|
|
};
|
|
|
|
# Shell aliases (migrated from 01-env.sh and 01-nvim.sh)
|
|
shellAliases = {
|
|
# Modern CLI replacements (from 01-env.sh)
|
|
ls = "eza";
|
|
cat = "bat";
|
|
grep = "rg";
|
|
diff = "delta";
|
|
less = "bat";
|
|
g = "git";
|
|
k = "kubectl --all-namespaces";
|
|
ssh = "TERM=screen ssh";
|
|
|
|
# Neovim alias (from 01-nvim.sh)
|
|
vim = "nvim";
|
|
vi = "nvim";
|
|
|
|
# Git root navigation (from 01-env.sh)
|
|
gr = "if [ \"`git rev-parse --show-cdup`\" != \"\" ]; then cd `git rev-parse --show-cdup`; fi";
|
|
|
|
# Misc
|
|
psf = "ps -aux | grep";
|
|
|
|
# Docker
|
|
docloc = "docker run --rm -it -v `PWD`:/usr/workdir --workdir=/usr/workdir";
|
|
|
|
# Nix
|
|
nsh = "nix-shell";
|
|
nse = "nix search nixpkgs";
|
|
};
|
|
|
|
# Additional initialization (initExtra)
|
|
# This runs after the shell is initialized
|
|
initContent = ''
|
|
# Source custom env file if it exists
|
|
[ -f ~/.env ] && source ~/.env
|
|
|
|
# Pinentry configuration for SSH sessions
|
|
if [[ -n "$SSH_CONNECTION" ]]; then
|
|
export PINENTRY_USER_DATA="USE_CURSES=1"
|
|
fi
|
|
|
|
function cd() {
|
|
builtin cd $*
|
|
ls
|
|
}
|
|
|
|
function mkd() {
|
|
mkdir $1
|
|
builtin cd $1
|
|
}
|
|
|
|
function take() { builtin cd $(mktemp -d) }
|
|
|
|
# Welcome banner (from dot_zshrc)
|
|
# Only show if terminal is wide enough
|
|
if [ `tput cols` -gt "70" ]; then
|
|
function PRINT_CENTER {
|
|
COLS=`tput cols`
|
|
OFFSET=$(( ($COLS - $1) / 2 ))
|
|
PRE=""
|
|
for i in `seq $OFFSET`; do
|
|
PRE="$PRE "
|
|
done
|
|
while IFS= read -r line; do
|
|
echo "$PRE$line"
|
|
done <<< "$2"
|
|
}
|
|
PRINT_CENTER 60 "
|
|
|
|
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
|
|
█░▄▄▀█▀▄▄▀█░▄▄░█▄░▄█▀▄▀██░▄░██░██░█░▄▄█░▄▄░█
|
|
█░▀▀▄█░██░█░▀▄░██░██░█▀█░▀▀░▀█░██░█▄▄▀███▄██
|
|
█▄█▄▄██▄▄██░▀▀░██▄███▄█████░███▄▄▄█▄▄▄█░▀▀░█
|
|
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
|
|
|
|
⣴⣶⣤⡤⠦⣤⣀⣤⠆ ⣈⣭⣿⣶⣿⣦⣼⣆
|
|
⠉⠻⢿⣿⠿⣿⣿⣶⣦⠤⠄⡠⢾⣿⣿⡿⠋⠉⠉⠻⣿⣿⡛⣦
|
|
⠈⢿⣿⣟⠦ ⣾⣿⣿⣷ ⠻⠿⢿⣿⣧⣄
|
|
⣸⣿⣿⢧ ⢻⠻⣿⣿⣷⣄⣀⠄⠢⣀⡀⠈⠙⠿⠄
|
|
⢠⣿⣿⣿⠈ ⣻⣿⣿⣿⣿⣿⣿⣿⣛⣳⣤⣀⣀
|
|
⢠⣧⣶⣥⡤⢄ ⣸⣿⣿⠘ ⢀⣴⣿⣿⡿⠛⣿⣿⣧⠈⢿⠿⠟⠛⠻⠿⠄
|
|
⣰⣿⣿⠛⠻⣿⣿⡦⢹⣿⣷ ⢊⣿⣿⡏ ⢸⣿⣿⡇ ⢀⣠⣄⣾⠄
|
|
⣠⣿⠿⠛ ⢀⣿⣿⣷⠘⢿⣿⣦⡀ ⢸⢿⣿⣿⣄ ⣸⣿⣿⡇⣪⣿⡿⠿⣿⣷⡄
|
|
⠙⠃ ⣼⣿⡟ ⠈⠻⣿⣿⣦⣌⡇⠻⣿⣿⣷⣿⣿⣿ ⣿⣿⡇ ⠛⠻⢷⣄
|
|
⢻⣿⣿⣄ ⠈⠻⣿⣿⣿⣷⣿⣿⣿⣿⣿⡟ ⠫⢿⣿⡆
|
|
⠻⣿⣿⣿⣿⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⡟⢀⣀⣤⣾⡿⠃
|
|
▄▄▄ . ▌ ▐·▪ ▄▄▌ ▄▄▌ ▐ ▄▌▪ ▄▄▄▄▄ ▄ .▄ ▄• ▄▌▄▄▄▄▄
|
|
▀▄.▀·▪█·█▌██ ██• ██· █▌▐███ •██ ██▪▐█ ▄█▀▄ █▪██▌•██
|
|
▐▀▀▪▄▐█▐█•▐█·██ ▪ ██▪▐█▐▐▌▐█· ▐█.▪██▀▀█▐█▌.▐▌█▌▐█▌ ▐█.▪
|
|
▐█▄▄▌ ███ ▐█▌▐█▌ ▄ ▐█▌██▐█▌▐█▌ ▐█▌·██▌▐▀▐█▌.▐▌▐█▄█▌ ▐█▌·
|
|
▀▀▀ . ▀ ▀▀▀.▀▀▀ ▀▀▀▀ ▀▪▀▀▀ ▀▀▀ ▀▀▀ · ▀█▄▀▪ ▀▀▀ ▀▀▀
|
|
|
|
> welcome x_x
|
|
"
|
|
fi
|
|
'';
|
|
|
|
# Profile extra (runs in .zprofile)
|
|
profileExtra = ''
|
|
# Add Rust/Cargo to PATH
|
|
export PATH="/opt/homebrew/opt/rustup/bin:$PATH:$HOME/.cargo/bin"
|
|
'';
|
|
};
|
|
|
|
# ==========================================================================
|
|
# Starship Prompt
|
|
# ==========================================================================
|
|
programs.starship = {
|
|
enable = true;
|
|
enableZshIntegration = true;
|
|
settings = {
|
|
add_newline = false;
|
|
character = {
|
|
success_symbol = "[λ](bold green)";
|
|
error_symbol = "[λ](bold red)";
|
|
};
|
|
};
|
|
};
|
|
|
|
# ==========================================================================
|
|
# Atuin - Shell History
|
|
# Migrated from dot_config/atuin/config.toml
|
|
# ==========================================================================
|
|
programs.atuin = {
|
|
enable = true;
|
|
enableZshIntegration = true;
|
|
|
|
settings = {
|
|
# Compact style for history display
|
|
style = "compact";
|
|
|
|
# Vim keybindings in normal mode
|
|
keymap_mode = "vim-normal";
|
|
};
|
|
};
|
|
|
|
# ==========================================================================
|
|
# Direnv - Directory-specific environments
|
|
# ==========================================================================
|
|
programs.direnv = {
|
|
enable = true;
|
|
enableZshIntegration = true;
|
|
|
|
# Enable nix-direnv for better Nix integration
|
|
nix-direnv.enable = true;
|
|
};
|
|
|
|
# ==========================================================================
|
|
# Zoxide - Smart directory navigation
|
|
# ==========================================================================
|
|
programs.zoxide = {
|
|
enable = true;
|
|
enableZshIntegration = true;
|
|
};
|
|
|
|
# ==========================================================================
|
|
# FZF - Fuzzy finder
|
|
# ==========================================================================
|
|
programs.fzf = {
|
|
enable = true;
|
|
enableZshIntegration = true;
|
|
};
|
|
|
|
# ==========================================================================
|
|
# Pyenv - Python version management
|
|
# ==========================================================================
|
|
programs.pyenv = {
|
|
enable = true;
|
|
enableZshIntegration = true;
|
|
};
|
|
|
|
programs.pet = {
|
|
enable = true;
|
|
};
|
|
|
|
programs.mise = {
|
|
enable = true;
|
|
enableZshIntegration = true;
|
|
enableNushellIntegration = true;
|
|
settings = {
|
|
experimental = true;
|
|
verbose = false;
|
|
auto_install = true;
|
|
};
|
|
};
|
|
|
|
home.activation.setupMise = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
|
# use the virtual environment created by uv
|
|
# ${pkgs.mise}/bin/mise settings set python.uv_venv_auto true
|
|
|
|
# enable corepack (pnpm, yarn, etc.)
|
|
${pkgs.mise}/bin/mise set MISE_NODE_COREPACK=true
|
|
|
|
# disable warning about */.node-version files
|
|
${pkgs.mise}/bin/mise settings add idiomatic_version_file_enable_tools "[]"
|
|
|
|
# set global tool versions (auto_install will handle installation)
|
|
${pkgs.mise}/bin/mise use --global node@lts
|
|
${pkgs.mise}/bin/mise use --global bun@latest
|
|
${pkgs.mise}/bin/mise use --global deno@latest
|
|
${pkgs.mise}/bin/mise use --global uv@latest
|
|
${pkgs.mise}/bin/mise use --global rust@latest
|
|
'';
|
|
|
|
programs.nushell = {
|
|
enable = true;
|
|
# The config.nu can be anywhere you want if you like to edit your Nushell with Nu
|
|
# configFile.source = ./.../config.nu;
|
|
# for editing directly to config.nu
|
|
extraConfig = ''
|
|
let carapace_completer = {|spans|
|
|
carapace $spans.0 nushell ...$spans | from json
|
|
}
|
|
$env.config = {
|
|
show_banner: false,
|
|
completions: {
|
|
case_sensitive: false # case-sensitive completions
|
|
quick: true # set to false to prevent auto-selecting completions
|
|
partial: true # set to false to prevent partial filling of the prompt
|
|
algorithm: "fuzzy" # prefix or fuzzy
|
|
external: {
|
|
# set to false to prevent nushell looking into $env.PATH to find more suggestions
|
|
enable: true
|
|
# set to lower can improve completion performance at the cost of omitting some options
|
|
max_results: 100
|
|
completer: $carapace_completer # check 'carapace_completer'
|
|
}
|
|
}
|
|
}
|
|
$env.PATH = ($env.PATH |
|
|
split row (char esep) |
|
|
append /usr/bin/env
|
|
)
|
|
'';
|
|
shellAliases = {
|
|
vi = "hx";
|
|
vim = "hx";
|
|
nano = "hx";
|
|
};
|
|
};
|
|
programs.carapace = {
|
|
enable = true;
|
|
enableNushellIntegration = true;
|
|
};
|
|
}
|