2023-02-11 00:08:58 +01:00
|
|
|
|
{ lib, pkgs, config, ... }:
|
2023-02-12 23:33:57 +01:00
|
|
|
|
|
2023-02-11 00:08:58 +01:00
|
|
|
|
with lib;
|
|
|
|
|
let
|
|
|
|
|
cfg = config.reo101.shell;
|
2023-02-12 23:33:57 +01:00
|
|
|
|
in
|
|
|
|
|
{
|
2023-02-17 01:47:22 +01:00
|
|
|
|
imports =
|
|
|
|
|
[
|
|
|
|
|
];
|
2023-02-11 00:08:58 +01:00
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
options =
|
|
|
|
|
{
|
|
|
|
|
reo101.shell = {
|
|
|
|
|
enable = mkEnableOption "reo101 zsh setup";
|
|
|
|
|
username = mkOption {
|
|
|
|
|
description = "Username to be used in prompt";
|
|
|
|
|
type = types.str;
|
|
|
|
|
default = "${config.home.username}";
|
|
|
|
|
};
|
2023-05-12 23:17:07 +02:00
|
|
|
|
atuin = mkOption {
|
|
|
|
|
description = "Integrate with atuin";
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = true;
|
|
|
|
|
};
|
2023-02-17 01:47:22 +01:00
|
|
|
|
direnv = mkOption {
|
|
|
|
|
description = "Integrate with direnv";
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = true;
|
|
|
|
|
};
|
|
|
|
|
zoxide = mkOption {
|
|
|
|
|
description = "Integrate with zoxide";
|
|
|
|
|
type = types.bool;
|
|
|
|
|
default = true;
|
|
|
|
|
};
|
|
|
|
|
extraConfig = mkOption {
|
|
|
|
|
type = types.str;
|
|
|
|
|
description = "Extra zsh config";
|
|
|
|
|
default = ''
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
};
|
2023-02-11 00:08:58 +01:00
|
|
|
|
};
|
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
config =
|
|
|
|
|
mkIf cfg.enable {
|
|
|
|
|
home.packages = with pkgs;
|
|
|
|
|
builtins.concatLists [
|
|
|
|
|
[
|
|
|
|
|
zsh
|
|
|
|
|
starship
|
|
|
|
|
]
|
2023-05-12 23:17:07 +02:00
|
|
|
|
(optionals cfg.atuin [
|
|
|
|
|
atuin
|
|
|
|
|
])
|
2023-02-17 01:47:22 +01:00
|
|
|
|
(optionals cfg.direnv [
|
2023-05-12 23:17:07 +02:00
|
|
|
|
direnv
|
2023-02-17 01:47:22 +01:00
|
|
|
|
])
|
|
|
|
|
(optionals cfg.zoxide [
|
2023-05-12 23:17:07 +02:00
|
|
|
|
zoxide
|
2023-02-17 01:47:22 +01:00
|
|
|
|
])
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
programs.direnv = mkIf cfg.direnv {
|
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
|
|
nix-direnv = {
|
|
|
|
|
enable = true;
|
|
|
|
|
};
|
|
|
|
|
};
|
2023-02-11 00:08:58 +01:00
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
programs.zsh = {
|
|
|
|
|
enable = true;
|
|
|
|
|
enableCompletion = true;
|
2023-02-11 00:08:58 +01:00
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
shellAliases = {
|
|
|
|
|
# ll = "ls -l";
|
|
|
|
|
# update = "sudo nixos-rebuild switch";
|
|
|
|
|
};
|
2023-02-11 00:08:58 +01:00
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
history = {
|
|
|
|
|
size = 10000;
|
|
|
|
|
path = "${config.xdg.dataHome}/zsh/history";
|
|
|
|
|
};
|
2023-02-11 00:08:58 +01:00
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
initExtra =
|
|
|
|
|
builtins.concatStringsSep "\n"
|
|
|
|
|
[
|
2023-05-12 23:17:07 +02:00
|
|
|
|
(optionalString cfg.atuin ''
|
|
|
|
|
export ATUIN_NOBIND="true"
|
|
|
|
|
eval "$(${pkgs.atuin}/bin/atuin init zsh)"
|
|
|
|
|
function zvm_after_init() {
|
|
|
|
|
# bindkey '^r' _atuin_search_widget
|
|
|
|
|
zvm_bindkey viins '^R' _atuin_search_widget
|
|
|
|
|
}
|
2023-02-17 01:47:22 +01:00
|
|
|
|
'')
|
2023-05-12 23:17:07 +02:00
|
|
|
|
# NOTE: done by `programs.direnv`
|
|
|
|
|
# (optionalString cfg.direnv ''
|
|
|
|
|
# eval "$(${pkgs.direnv}/bin/direnv hook zsh)"
|
|
|
|
|
# '')
|
2023-02-17 01:47:22 +01:00
|
|
|
|
(optionalString cfg.zoxide ''
|
2023-05-12 23:17:07 +02:00
|
|
|
|
eval "$(${pkgs.zoxide}/bin/zoxide init zsh)"
|
2023-02-17 01:47:22 +01:00
|
|
|
|
'')
|
|
|
|
|
cfg.extraConfig
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
plugins = [
|
|
|
|
|
{
|
|
|
|
|
name = "zsh-nix-shell";
|
|
|
|
|
file = "nix-shell.plugin.zsh";
|
|
|
|
|
src = pkgs.fetchFromGitHub {
|
|
|
|
|
owner = "chisui";
|
|
|
|
|
repo = "zsh-nix-shell";
|
|
|
|
|
rev = "v0.5.0";
|
|
|
|
|
sha256 = "0za4aiwwrlawnia4f29msk822rj9bgcygw6a8a6iikiwzjjz0g91";
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
name = "fast-syntax-highlighting";
|
2023-04-17 10:44:54 +02:00
|
|
|
|
file = "fast-syntax-highlighting.plugin.zsh";
|
2023-02-17 01:47:22 +01:00
|
|
|
|
src = pkgs.fetchFromGitHub {
|
2023-04-17 10:44:54 +02:00
|
|
|
|
owner = "zdharma-continuum";
|
2023-02-17 01:47:22 +01:00
|
|
|
|
repo = "fast-syntax-highlighting";
|
2023-04-17 10:44:54 +02:00
|
|
|
|
rev = "13d7b4e63468307b6dcb2dadf6150818f242cbff";
|
|
|
|
|
sha256 = "sha256-AmsexwVombgVmRvl4O9Kd/WbnVJHPTXETxBv18PDHz4=";
|
2023-02-17 01:47:22 +01:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
name = "zsh-vi-mode";
|
|
|
|
|
file = "zsh-vi-mode.plugin.zsh";
|
|
|
|
|
src = pkgs.fetchFromGitHub {
|
|
|
|
|
owner = "jeffreytse";
|
|
|
|
|
repo = "zsh-vi-mode";
|
|
|
|
|
rev = "v0.9.0";
|
|
|
|
|
sha256 = "sha256-KQ7UKudrpqUwI6gMluDTVN0qKpB15PI5P1YHHCBIlpg=";
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
};
|
2023-02-11 00:08:58 +01:00
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
programs.starship = {
|
|
|
|
|
enable = true;
|
2023-02-11 00:08:58 +01:00
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
settings = {
|
|
|
|
|
# Get editor completions based on the config schema
|
|
|
|
|
"$schema" = "https://starship.rs/config-schema.json";
|
2023-02-11 00:08:58 +01:00
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
# Use custom format
|
|
|
|
|
format = ''
|
2023-02-19 11:49:42 +01:00
|
|
|
|
[╭───────┨](bold green)[${cfg.username}](bright-white)[@](bold yellow)$hostname[┠───────>](bold green)$status$cmd_duration$git_branch$git_status$git_state$git_commit
|
2023-02-17 01:47:22 +01:00
|
|
|
|
[│](bold green)$time$jobs: $directory$package
|
|
|
|
|
[╰─](bold green)$character
|
|
|
|
|
'';
|
2023-02-11 00:08:58 +01:00
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
# ${custom.local}\
|
|
|
|
|
# ${custom.local_root}\
|
|
|
|
|
# ${custom.ssh}\
|
|
|
|
|
# ${custom.ssh_root}\
|
2023-02-11 00:08:58 +01:00
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
add_newline = true;
|
2023-02-11 00:08:58 +01:00
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
character = {
|
|
|
|
|
success_symbol = "[→](bold green)";
|
|
|
|
|
error_symbol = "[→](red)";
|
|
|
|
|
};
|
2023-02-11 00:08:58 +01:00
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
git_branch = {
|
|
|
|
|
symbol = "🌱 ";
|
|
|
|
|
truncation_length = 15;
|
|
|
|
|
truncation_symbol = "…"; # …
|
|
|
|
|
};
|
2023-02-11 00:08:58 +01:00
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
git_commit = {
|
|
|
|
|
commit_hash_length = 6;
|
|
|
|
|
tag_symbol = "🔖 ";
|
|
|
|
|
};
|
2023-02-11 00:08:58 +01:00
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
git_state = {
|
|
|
|
|
format = "[\($state( $progress_current of $progress_total)\)]($style) ";
|
|
|
|
|
cherry_pick = "[🍒 PICKING](bold red)";
|
|
|
|
|
};
|
2023-02-11 00:08:58 +01:00
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
git_status = {
|
|
|
|
|
# conflicted = "🏳";
|
|
|
|
|
# ahead = "🏎💨";
|
|
|
|
|
# behind = "😰";
|
|
|
|
|
# diverged = "😵";
|
|
|
|
|
# untracked = "🤷";
|
|
|
|
|
# stashed = "📦";
|
|
|
|
|
# modified = "📝";
|
|
|
|
|
# staged = '[++\($count\)](green)';
|
|
|
|
|
# renamed = "👅";
|
|
|
|
|
# deleted = "🗑";
|
|
|
|
|
format = "[\\[$all_status$ahead_behind\\]]($style) ";
|
|
|
|
|
conflicted = "=[\($count\)](green) ";
|
|
|
|
|
ahead = "⇡[\($count\)](green) ";
|
|
|
|
|
behind = "⇣[\($count\)](green) ";
|
|
|
|
|
diverged = "⇕[\($count\)](green) ";
|
|
|
|
|
untracked = "?[\($count\)](green) ";
|
|
|
|
|
stashed = "$[\($count\)](green) ";
|
|
|
|
|
modified = "![\($count\)](green) ";
|
|
|
|
|
staged = "+[\($count\)](green) ";
|
|
|
|
|
renamed = "»[\($count\)](green) ";
|
|
|
|
|
deleted = "✘[\($count\)](green) ";
|
|
|
|
|
};
|
2023-02-11 00:08:58 +01:00
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
status = {
|
|
|
|
|
style = "bg:blue fg:red";
|
|
|
|
|
symbol = "🔴";
|
|
|
|
|
format = "[\[$symbol $common_meaning$signal_name$maybe_int\]]($style) ";
|
|
|
|
|
map_symbol = true;
|
|
|
|
|
disabled = false;
|
|
|
|
|
};
|
2023-02-11 00:08:58 +01:00
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
time = {
|
|
|
|
|
disabled = false;
|
|
|
|
|
format = "🕙[$time]($style) ";
|
|
|
|
|
# format = '🕙[\[ $time \]]($style) ';
|
|
|
|
|
time_format = "%T";
|
|
|
|
|
utc_time_offset = "+3";
|
|
|
|
|
# time_range = "10:00:00-14:00:00";
|
|
|
|
|
};
|
2023-02-11 00:08:58 +01:00
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
cmd_duration = {
|
|
|
|
|
min_time = 2000; # miliseconds
|
|
|
|
|
# show_notifications = true;
|
|
|
|
|
min_time_to_notify = 45000; # miliseconds
|
|
|
|
|
format = "took [$duration](bold yellow) ";
|
|
|
|
|
};
|
2023-02-11 00:08:58 +01:00
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
hostname = {
|
|
|
|
|
ssh_only = false;
|
|
|
|
|
format = "[$hostname](bold fg:#CC59B0)";
|
|
|
|
|
disabled = false;
|
|
|
|
|
};
|
2023-02-11 00:08:58 +01:00
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
username = {
|
|
|
|
|
disabled = false;
|
|
|
|
|
style_user = "white bold";
|
|
|
|
|
style_root = "red bold";
|
|
|
|
|
format = "[$user]($style)[@](bold yellow)";
|
|
|
|
|
show_always = true;
|
|
|
|
|
};
|
2023-02-11 00:08:58 +01:00
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
directory = {
|
|
|
|
|
read_only = "🔒";
|
|
|
|
|
read_only_style = "bold white";
|
|
|
|
|
style = "fg:#A7F3E4";
|
|
|
|
|
truncate_to_repo = false;
|
|
|
|
|
truncation_length = 5;
|
|
|
|
|
truncation_symbol = "…/";
|
|
|
|
|
home_symbol = "🏡";
|
|
|
|
|
format = "[$read_only]($read_only_style)[$path]($style) ";
|
|
|
|
|
};
|
2023-02-11 00:08:58 +01:00
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
directory.substitutions = {
|
|
|
|
|
".config" = " ";
|
|
|
|
|
"nvim" = "";
|
|
|
|
|
"emacs" = "𝓔";
|
|
|
|
|
"doom" = "𝓔";
|
|
|
|
|
"Projects" = "💻";
|
|
|
|
|
"FMI" = "🏫";
|
|
|
|
|
"Home" = "🏠";
|
|
|
|
|
"CPP" = "";
|
|
|
|
|
"Java" = "";
|
|
|
|
|
"Python" = "";
|
|
|
|
|
};
|
2023-02-11 00:08:58 +01:00
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
# Language Environments
|
|
|
|
|
package = {
|
|
|
|
|
style = "bold fg:#5E5E5E";
|
|
|
|
|
};
|
2023-02-11 00:08:58 +01:00
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
python = {
|
|
|
|
|
style = "bold fg:#5E5E5E";
|
|
|
|
|
symbol = "[](bold yellow) ";
|
|
|
|
|
};
|
2023-02-11 00:08:58 +01:00
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
nodejs = {
|
|
|
|
|
style = "bold fg:#5E5E5E";
|
|
|
|
|
symbol = "[⬢](bold green) ";
|
|
|
|
|
};
|
2023-02-11 00:08:58 +01:00
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
# Custom
|
|
|
|
|
jobs = {
|
|
|
|
|
format = "[ $symbol$number ]($style)";
|
|
|
|
|
style = "bg:#587744 fg:bright-white";
|
|
|
|
|
symbol = "⚙";
|
|
|
|
|
};
|
2023-02-11 00:08:58 +01:00
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
custom.local = {
|
|
|
|
|
shell = [ "zsh" "-d" "-f" ];
|
|
|
|
|
when = '' [ [ -z "$SSH_CLIENT" ] ] && [ [ `whoami` != "root" ] ] '';
|
|
|
|
|
format = "[$symbol$output]($style)[@](bold yellow)";
|
|
|
|
|
command = "whoami";
|
|
|
|
|
style = "fg:bright-white";
|
|
|
|
|
symbol = "";
|
|
|
|
|
};
|
2023-02-11 00:08:58 +01:00
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
custom.local_root = {
|
|
|
|
|
shell = [ "zsh" "-d" "-f" ];
|
|
|
|
|
when = '' [ [ -z "$SSH_CLIENT" ] ] && [ [ `whoami` == "root" ] ] '';
|
|
|
|
|
format = "[ $output ]($style)[@](bold yellow)";
|
|
|
|
|
command = "whoami";
|
|
|
|
|
style = "bg:red fg:bright-white";
|
|
|
|
|
};
|
2023-02-11 00:08:58 +01:00
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
custom.ssh = {
|
|
|
|
|
shell = [ "zsh" "-d" "-f" ];
|
|
|
|
|
when = '' [ [ -n "$SSH_CLIENT" ] ] && [ [ `whoami` != "root" ] ] '';
|
|
|
|
|
format = "[ $symbol$output ]($style)[@](bold yellow)";
|
|
|
|
|
command = "whoami";
|
|
|
|
|
style = "bg:blue fg:bright-white";
|
|
|
|
|
# style = "bg:#FD7208 fg:bright-white";
|
|
|
|
|
symbol = "⌁";
|
|
|
|
|
};
|
2023-02-11 00:08:58 +01:00
|
|
|
|
|
2023-02-17 01:47:22 +01:00
|
|
|
|
custom.ssh_root = {
|
|
|
|
|
shell = [ "zsh" "-d" "-f" ];
|
|
|
|
|
when = '' [ [ -n "$SSH_CLIENT" ] ] && [ [ `whoami` == "root" ] ] '';
|
|
|
|
|
format = "[ $symbol$output ]($style)[@](bold yellow)";
|
|
|
|
|
command = "whoami";
|
|
|
|
|
style = "bg:red fg:bright-white";
|
|
|
|
|
symbol = "⌁";
|
|
|
|
|
};
|
2023-02-11 00:08:58 +01:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
2023-02-12 23:33:57 +01:00
|
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
|
maintainers = with lib.maintainers; [ reo101 ];
|
|
|
|
|
};
|
2023-02-11 00:08:58 +01:00
|
|
|
|
}
|