nichts/modules/cli/zsh.nix

99 lines
3.7 KiB
Nix
Raw Normal View History

2024-04-10 17:39:26 +02:00
{ config, lib, pkgs, ... }:
with lib; let
2024-04-12 22:03:29 +02:00
cfg = config.modules.programs.zsh;
username = config.modules.other.system.username;
hostname = config.modules.other.system.hostname;
gitPath = config.modules.other.system.gitPath;
2024-04-10 17:39:26 +02:00
in {
2024-04-12 22:03:29 +02:00
options.modules.programs.zsh = {
2024-04-10 17:39:26 +02:00
enable = mkEnableOption "zsh";
extraAliases = mkOption {
type = types.attrs;
description = "extra shell aliases";
default = {};
};
profiling = mkOption {
type = types.bool;
description = "enable zsh profiling";
default = false;
};
ohmyzsh = {
enable = mkEnableOption "ohmyzsh";
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)";
2024-04-12 15:57:39 +02:00
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";
ls = "eza";
2024-04-10 17:39:26 +02:00
l = "eza -a --icons";
la = "eza -lha --icons --git";
ll = "eza -l";
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-12 16:12:02 +02:00
update = "sudo -p 'password: ' echo 'Your daughter is just a fork of your wife.' && sudo nixos-rebuild switch --flake \"${gitPath}#${hostname}\" --log-format internal-json |& nom --json";
flake = "cd '${gitPath}'";
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 15:24:35 +02:00
oh-my-zsh = mkIf cfg.ohmyzsh.enable {
2024-04-13 18:34:33 +02:00
enable = true;
theme = cfg.ohmyzsh.theme;
2024-04-12 16:20:03 +02:00
plugins = cfg.ohmyzsh.plugins;
};
2024-04-10 17:39:26 +02:00
};
};
};
}