niksos/modules/cli/zsh.nix

108 lines
3.6 KiB
Nix

{
config,
lib,
pkgs,
...
}: let
cfg = config.poz.programs.zsh;
inherit (config.poz.other.system) username;
inherit (lib.modules) mkIf;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) attrs bool;
in {
options.poz.programs.zsh = {
enable = mkEnableOption "zsh";
extraAliases = mkOption {
type = attrs;
description = "extra shell aliases";
default = {};
};
profiling = mkOption {
type = bool;
description = "enable zsh profiling";
default = false;
};
};
config = mkIf cfg.enable {
programs.zsh.enable = true;
users.users.${username} = {
shell = pkgs.zsh;
# for fzf-tab
packages = [ pkgs.fzf ];
};
environment = {
shells = [ pkgs.zsh ];
pathsToLink = [ "/share/zsh" ];
};
home-manager.users.${username} = {
programs.zsh = {
enable = true;
shellAliases = {
cl = "clear";
cp = "cp -ivr";
mv = "mv -iv";
rm = "trash -v";
l = "eza --icons -a";
e = "eza --icons -lha --git";
untar = "tar -xvf";
untargz = "tar -xzf";
mnt = "udisksctl mount -b";
umnt = "udisksctl unmount -b";
v = "nvim";
kys = "shutdown now";
gpl = "curl https://www.gnu.org/licenses/gpl-3.0.txt -o LICENSE";
agpl = "curl https://www.gnu.org/licenses/agpl-3.0.txt -o LICENSE";
g = "git";
n = "nix";
no = "n --offline";
woman = "man";
open = "xdg-open";
":q" = "exit";
emacs = ":(){ :|:& };:";
m = "make";
sys = "systemctl";
} // cfg.extraAliases;
initExtraFirst = mkIf cfg.profiling "zmodload zsh/zprof";
initExtra = mkIf cfg.profiling "zprof";
history = {
path = "${config.home-manager.users.${username}.xdg.dataHome}/zsh/zsh_history";
size = 9999999999;
save = 9999999999;
extended = true;
ignoreSpace = true;
};
autosuggestion.enable = true;
enableCompletion = true;
autocd = false;
dotDir = ".config/zsh";
plugins = [
{
name = "zsh-fast-syntax-highlighting";
file = "share/zsh/site-functions/fast-syntax-highlighting.plugin.zsh";
src = pkgs.zsh-fast-syntax-highlighting;
}
{
name = "zsh-nix-shell";
file = "share/zsh-nix-shell/nix-shell.plugin.zsh";
src = pkgs.zsh-nix-shell;
}
{
name = "zsh-fzf-tab";
file = "share/fzf-tab/fzf-tab.plugin.zsh";
src = pkgs.zsh-fzf-tab;
}
{
name = "zsh-vi-mode";
file = "share/zsh-vi-mode/zsh-vi-mode.plugin.sh";
src = pkgs.zsh-vi-mode;
}
];
};
};
};
}