nichts/modules/cli/zsh.nix

94 lines
3.4 KiB
Nix
Raw Normal View History

2024-04-10 17:39:26 +02:00
{ config, lib, pkgs, ... }:
with lib; let
cfg = config.myOptions.programs.zsh;
username = config.myOptions.other.system.username;
in {
options.myOptions.programs.zsh = {
enable = mkEnableOption "zsh";
extraAliases = mkOption {
type = types.attrs;
description = "extra shell aliases";
default = {};
};
profiling = mkOption {
type = types.bool;
description = "enable zsh profiling";
default = false;
};
2024-04-12 08:13:54 +02:00
oh-my-zsh = {
enable = mkEnableOption "oh-my-zsh";
theme = mkOption {
type = types.str;
description = "oh-my-zsh theme";
default = "alanpeabody";
};
plugins = mkOption {
type = types.listOf(types.str);
description = "oh-my-zsh plugins (like git)";
default = ["git"];
};
};
2024-04-10 17:39:26 +02:00
};
config = mkIf cfg.enable {
programs.zsh.enable = true;
2024-04-10 19:31:40 +02:00
users.users.${username}.shell = pkgs.zsh;
2024-04-10 17:39:26 +02:00
environment = {
shells = [ pkgs.zsh ];
pathsToLink = [ "/share/zsh" ];
};
home-manager.users.${username} = {
home.packages = with pkgs; [ nix-output-monitor ];
programs.zoxide.enable = true;
programs.zoxide.enableZshIntegration = true;
2024-04-10 17:39:26 +02:00
programs.zsh = {
enable = true;
shellAliases = {
c = "clear";
cc = "cd ~ && clear";
2024-04-10 17:39:26 +02:00
mv = "mv -iv";
rm = "trash -v";
l = "eza -a --icons";
la = "eza -lha --icons --git";
2024-04-11 09:00:29 +02:00
kys = "shutdown now";
cd = "z";
2024-04-10 21:37:26 +02:00
nv = "nvim";
#TODO fix hardcoding of git repo path and profile name
2024-04-11 22:16:07 +02:00
update = "sudo -p 'password: ' echo 'Your daughter is just a fork of your wife.' && sudo nixos-rebuild switch --flake \"$HOME/nichts#${config.myOptions.other.system.hostname}\" --log-format internal-json |& nom --json";
2024-04-10 17:39:26 +02:00
} // cfg.extraAliases;
initExtraFirst = mkIf cfg.profiling "zmodload zsh/zprof";
initExtra = mkIf cfg.profiling "zprof";
2024-04-10 19:21:46 +02:00
history = {
2024-04-10 17:39:26 +02:00
path = "${config.home-manager.users.${username}.xdg.dataHome}/zsh/zsh_history";
size = 99999;
save = 99999;
extended = true;
ignoreSpace = true;
};
autosuggestion.enable = true;
enableCompletion = true;
autocd = false;
dotDir = ".config/zsh";
plugins = [
{
name = "fast-syntax-highlighting";
file = "fast-syntax-highlighting.plugin.zsh";
src = pkgs.fetchFromGitHub {
owner = "zdharma-continuum";
repo = "fast-syntax-highlighting";
rev = "cf318e06a9b7c9f2219d78f41b46fa6e06011fd9";
sha256 = "sha256-RVX9ZSzjBW3LpFs2W86lKI6vtcvDWP6EPxzeTcRZua4=";
};
}
];
2024-04-12 08:13:54 +02:00
oh-my-zsh = mkIf cfg.oh-my-zsh.enable {
enable = cfg.oh-my-zsh.enable;
theme = cfg.oh-my-zsh.theme;
plugins = cfg.oh-my-zsh.plugins;
};
2024-04-10 17:39:26 +02:00
};
};
};
}