lifetracker/modules/apps/zsh/default.nix
2025-02-01 11:12:58 -08:00

81 lines
1.9 KiB
Nix

{
lib,
config,
pkgs,
username,
...
}:
let
cfg = config.zsh;
in
{
options = {
zsh = {
enable = lib.mkEnableOption "Enable zsh in NixOS";
};
};
config = lib.mkIf cfg.enable {
programs = {
zsh.enable = true;
zsh.shellInit = "autoload -U add-zsh-hook";
};
environment.shells = with pkgs; [ zsh ];
home-manager.users.${username} =
{
inputs,
config,
pkgs,
...
}:
{
programs.zsh = {
enable = true;
autosuggestion.enable = true;
enableCompletion = true;
syntaxHighlighting.enable = true;
dotDir = ".config/zsh";
history = {
path = "${config.xdg.dataHome}/zsh/zsh_history";
size = 999999999;
extended = true;
ignoreSpace = true;
};
initExtra = ''
autoload -U add-zsh-hook
export GITHUB_TOKEN="$(cat ${config.sops.secrets."github_token".path})"
[ "$TERM" = "xterm-kitty" ] && alias ssh="kitty +kitten ssh"
'';
oh-my-zsh = {
enable = true;
custom = "${config.xdg.configHome}/zsh/.zsh_custom";
plugins = [
"command-not-found"
"direnv"
"git"
"sudo"
];
};
plugins = [
{
name = "cd-ls";
src = inputs.cd-ls;
file = "cd-ls.plugin.zsh";
}
{
name = "zsh-fast-syntax-highlighting";
src = pkgs.zsh-fast-syntax-highlighting;
file = "share/zsh/site-functions/fast-syntax-highlighting.plugin.zsh";
}
{
name = "nix-zsh-completions";
src = pkgs.nix-zsh-completions;
file = "share/zsh/site-functions/nix-zsh-completions.plugin.zsh";
}
];
};
};
};
}