Files
nixos/Droidnix/generated/system/applications/terminal_shell/zsh.nix
T
2026-03-07 23:29:39 +01:00

92 lines
2.6 KiB
Nix

{
config,
pkgs,
lib,
user,
...
}:
let
zshConfigDir = "${config.home-manager.users.${user.username}.xdg.configHome}/zsh";
in
{
home-manager.users.${user.username} = {
# Install and enable Zsh
programs.zsh = {
enable = true;
enableCompletion = true;
dotDir = zshConfigDir;
autosuggestions.enable = true;
syntaxHighlighting.enable = true;
oh-my-zsh = {
enable = true;
theme = "agnoster"; # Popular minimal theme
plugins = [
"git"
"sudo"
"docker"
"kubectl"
"zsh-autosuggestions"
"zsh-syntax-highlighting"
"history"
"command-not-found"
"extract"
"colored-man-pages"
];
};
# Shell options (setopt)
shellAliases = {
ls = "exa --icons -a --group-directories-first";
ll = "exa --icons -la --group-directories-first";
grep = "grep --color=auto";
};
};
# Consolidated .zshrc with best practices
xdg.configFile."zsh/.zshrc".text = lib.concatStringsSep "\n" [
"# Enable Powerlevel10k (if installed)"
"${pkgs.zsh-powerlevel10k}/share/zsh-powerlevel10k/powerlevel10k.zsh-theme"
"# Oh-My-Zsh"
"export ZSH=\"${zshConfigDir}\""
"source \"${pkgs.zsh}/share/zsh/functions/Newuser/zsh-newuser-install\""
"source \"${zshConfigDir}/oh-my-zsh.sh\""
""
"# Zsh options"
"setopt AUTO_CD"
"setopt CORRECT"
"setopt INTERACTIVE_COMMENTS"
"setopt APPEND_HISTORY"
"setopt INC_APPEND_HISTORY"
"setopt HIST_IGNORE_ALL_DUPS"
"setopt HIST_REDUCE_BLANKS"
"setopt HIST_SAVE_NO_DUPS"
"setopt HIST_VERIFY"
"setopt SHARE_HISTORY"
""
"# Starship prompt (if enabled)"
"eval \"$(starship init zsh)\""
""
"# fzf key bindings and completion"
"source \"${pkgs.fzf}/shell/key-bindings.zsh\""
"source \"${pkgs.fzf}/shell/completion.zsh\""
""
"# Load direnv"
"eval \"$(direnv hook zsh)\""
""
"# Load nix-direnv (if using direnv with Nix)"
"if [ -f \"${pkgs.nix-direnv}/share/nix-direnv/direnvrc\" ]; then"
" source \"${pkgs.nix-direnv}/share/nix-direnv/direnvrc\""
"fi"
""
"# User-specific customizations"
"source \"${zshConfigDir}/custom.zsh\" 2>/dev/null"
];
# Optional: User customizations (managed separately)
xdg.configFile."zsh/custom.zsh".text = ''
# Add your custom aliases, functions, and exports here
export EDITOR="nvim"
export PATH="$HOME/.local/bin:$PATH"
'';
};
}