fixed zshell.nix, decided to consolidate all declared home files into files.nix instead of having a dedicated directory

This commit is contained in:
pagedmov
2024-11-02 05:49:22 -04:00
parent acfea079b1
commit 44e1498e97
7 changed files with 182 additions and 300 deletions

View File

@@ -12,7 +12,7 @@
./programs
./environment
./scripts
./files
./files.nix
];
# ./files

View File

@@ -11,7 +11,7 @@
right_format = "($custom)";
format = lib.concatStrings [
"($username)($ssh_symbol)($hostname)(bold white)($cmd_duration)($character)"
"($ssh_symbol)($username)($hostname)(bold white)($cmd_duration)($character)"
"($git_branch)($git_status)($rust)($nix-shell)"
"($directory)"
"$line_break[ > ](bold #89b4fa)"
@@ -48,17 +48,18 @@
style = "bold purple";
};
hostname = {
ssh_symbol = "🌐";
ssh_only = false;
format = "[$ssh_symbol](bold blue)[$hostname](bold red)";
};
hostname = {
ssh_symbol = "🌐";
ssh_only = false;
format = "[@](bold blue)[$hostname](bold red)";
};
custom.shellver = {
command = "zsh --version";
when = ''test $SHELL = "/run/current-system/sw/bin/zsh"'';
symbol = "";
style = "bold magenta";
custom.shellver = {
command = "zsh --version";
when = ''test $SHELL = "/run/current-system/sw/bin/zsh"'';
symbol = "";
style = "bold magenta";
};
};
};
};

View File

@@ -9,128 +9,25 @@
};
programs.zsh = {
enable = true;
highlight = "fg=#4C566A,underline";
};
shellAliases = {
grep = "grep --color=auto";
yazi = "y";
vi = "nvim";
mv = "mv -v";
cp = "cp -vr";
gt = "gtrash";
gtp = "playshellsound ${self}/assets/sound/rm.wav; gtrash put";
sr = "source ~/.zshrc";
".." = "cd ..";
rm = "echo 'use \"gtp\" instead'";
psg = "ps aux | grep -v grep | grep -i -e VSZ -e";
mkdir = "mkdir -p";
pk = "pkill -9 -f";
svcu = "systemctl --user";
svc = "sudo systemctl";
viflake = "nvim flake.nix";
#git
"ga" = "playshellsound ${self}/assets/sound/gitadd.wav; git add";
gco = "gitcheckout_sfx";
gcomm = "gitcommit_sfx";
gpush = "gitpush_sfx";
gpull = "gitpull_sfx";
greb = "gitrebase_sfx";
};
initExtra = ''
playshellsound() {
if [ $# -ne 1 ]; then
echo "Usage: playshellsound <path/to/sound>"
return 1
fi
if ! scheck; then
return 0
else
runbg aplay "$1"
fi
}
gitcheckout_sfx() {
if git checkout "$@"; then
playshellsound ${self}/assets/sound/gitcheckout.wav
return 0
else
playshellsound ${self}/assets/sound/error.wav
return 1
fi
}
gitrebase_sfx() {
if git rebase "$@"; then
playshellsound ${self}/assets/sound/gitrebase.wav
return 0
else
playshellsound ${self}/assets/sound/error.wav
return 1
fi
}
gitcommit_sfx() {
if git commit "$@"; then
playshellsound ${self}/assets/sound/gitcommit.wav
return 0
else
playshellsound ${self}/assets/sound/error.wav
return 1
fi
}
gitpush_sfx() {
if git push "$@"; then
playshellsound ${self}/assets/sound/gitpush.wav
return 0
else
playshellsound ${self}/assets/sound/error.wav
return 1
fi
}
gitpull_sfx() {
if git pull "$@"; then
playshellsound ${self}/assets/sound/gitpull.wav
return 0
else
playshellsound ${self}/assets/sound/error.wav
return 1
fi
}
unalias ls
ls() {
eza -1 --group-directories-first --icons "$@"
playshellsound ${self}/assets/sound/ls.wav
return 0
}
mkcd() {
mkdir -p "$1" && cd "$1"
}
y() {
local tmp="$(mktemp -t "yazi-cwd.XXXXXX")"
yazi "$@" --cwd-file="$tmp"
if cwd="$(command cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
builtin cd -- "$cwd"
fi
rm -f -- "$tmp"
}
cd() {
local prev_sounds_enabled="$SOUNDS_ENABLED"
SOUNDS_ENABLED=0
eza -1 --group-directories-first --icons "$@"
SOUNDS_ENABLED=$prev_sounds_enabled
builtin cd "$@"
playshellsound /nix/store/7a9w7np3qrvmzxjbs7xj05qq2yccgfsj-source/assets/sound/cd.wav
return 0
}
if [ ! -e $HOME/.zsh_history ]; then
touch $HOME/.zsh_history
chmod 600 $HOME/.zsh_history
fi
setopt APPEND_HISTORY # Append history to the history file (don't overwrite)
setopt INC_APPEND_HISTORY # Append to the history file incrementally
setopt SHARE_HISTORY # Share history between all zsh sessions
shellAliases = {
grep = "grep --color=auto";
yazi = "y";
vi = "nvim";
mv = "mv -v";
cp = "cp -vr";
gt = "gtrash";
gtp = "playshellsound ${self}/assets/sound/rm.wav; gtrash put";
sr = "source ~/.zshrc";
".." = "cd ..";
rm = "echo 'use \"gtp\" instead'";
psg = "ps aux | grep -v grep | grep -i -e VSZ -e";
mkdir = "mkdir -p";
pk = "pkill -9 -f";
svcu = "systemctl --user";
svc = "sudo systemctl";
viflake = "nvim flake.nix";
};
sessionVariables = {
SOUNDS_ENABLED = "1";
@@ -160,31 +57,6 @@
highlight = "fg=#4C566A,underline";
};
shellAliases = {
grep = "grep --color=auto";
yazi = "y";
vi = "nvim";
mv = "mv -v";
cp = "cp -vr";
gt = "gtrash";
gtp = "playshellsound ${self}/assets/sound/rm.wav; gtrash put";
sr = "source ~/.zshrc";
".." = "cd ..";
rm = "echo 'use \"gtp\" instead'";
psg = "ps aux | grep -v grep | grep -i -e VSZ -e";
mkdir = "mkdir -p";
pk = "pkill -9 -f";
svcu = "systemctl --user";
svc = "sudo systemctl";
viflake = "nvim flake.nix";
#git
"ga" = "playshellsound ${self}/assets/sound/gitadd.wav; git add";
gcomm = "gitcommit_sfx";
gpush = "gitpush_sfx";
gpull = "gitpull_sfx";
greb = "gitrebase_sfx";
};
initExtra = ''
playshellsound() {
if [ $# -ne 1 ]; then
@@ -197,6 +69,15 @@
runbg aplay "$1"
fi
}
gitcheckout_sfx() {
if git checkout "$@"; then
playshellsound ${self}/assets/sound/gitcheckout.wav
return 0
else
playshellsound ${self}/assets/sound/error.wav
return 1
fi
}
gitrebase_sfx() {
if git rebase "$@"; then
playshellsound ${self}/assets/sound/gitrebase.wav
@@ -270,7 +151,6 @@
setopt INC_APPEND_HISTORY # Append to the history file incrementally
setopt SHARE_HISTORY # Share history between all zsh sessions
sessionVariables = {
setopt CORRECT
setopt NO_NOMATCH
setopt LIST_PACKED

120
modules/home/files.nix Normal file
View File

@@ -0,0 +1,120 @@
{ lib, self, config, ... }:
# This folder is for programs that do not have existing configuration modules in NixOS.
# Basically a to-do list for stuff I need to write my own modules for.
{
options = {
homeFiles.enable = lib.mkEnableOption "enables declared custom files";
};
config = {
home.file = {
".config/neofetch/config.conf".text = ''
username=$(whoami)
name_length=''${#username}
total_width=40
side_length=$(( (total_width - name_length - 2) / 2 ))
top_line=$(printf "%.0s" $(seq 1 $side_length))
top_line="$top_line $username "
top_line+=$(printf "%.0s" $(seq 1 $side_length))
if (( (total_width - name_length) % 2 != 0 )); then
top_line+=""
fi
print_info() {
prin "$top_line"
info " " distro
info " " kernel
info " " wm
info " " shell
info " " term
info " " term_font
info " 󰏗 " packages
prin ""
info cols
prin "\n \n \n \n \n ''${cl3} \n \n ''${cl5} \n \n ''${cl2} \n \n ''${cl6} \n \n ''${cl4} \n \n ''${cl1} \n \n ''${cl7} \n \n ''${cl0}"
}
kernel_shorthand="on"
distro_shorthand="on"
os_arch="off"
uptime_shorthand="on"
memory_percent="on"
package_managers="off"
shell_path="off"
shell_version="on"
speed_type="bios_limit"
speed_shorthand="on"
gtk_shorthand="on"
gtk2="on"
gtk3="on"
colors=(distro)
bold="on"
underline_enabled="on"
underline_char="-"
separator=" "
color_blocks="off"
block_range=(0 15) # Colorblocks
# Colors for custom colorblocks
magenta="\033[1;35m"
green="\033[1;32m"
white="\033[1;37m"
blue="\033[1;34m"
red="\033[1;31m"
black="\033[1;40;30m"
yellow="\033[1;33m"
cyan="\033[1;36m"
reset="\033[0m"
bgyellow="\033[1;43;33m"
bgwhite="\033[1;47;37m"
cl0="''${reset}"
cl1="''${magenta}"
cl2="''${green}"
cl3="''${white}"
cl4="''${blue}"
cl5="''${red}"
cl6="''${yellow}"
cl7="''${cyan}"
cl8="''${black}"
cl9="''${bgyellow}"
cl10="''${bgwhite}"
block_width=4
block_height=1
bar_char_elapsed="-"
bar_char_total="="
bar_border="on"
bar_length=15
bar_color_elapsed="distro"
bar_color_total="distro"
cpu_display="on"
memory_display="on"
battery_display="on"
disk_display="on"
image_backend="kitty"
image_source="${self}/assets/images/nixos-logo.png"
image_size="250px"
image_loop="off"
aascii_distro="auto"
ascii_colors=(distro)
ascii_bold="on"
crop_mode="normal"
crop_offset="center"
gap=2
yoffset=0
xoffset=0
stdout="off"
'';
};
};
}

View File

@@ -1,7 +0,0 @@
{ ... }:
# This folder is for programs that do not have existing configuration modules in NixOS.
# Basically a to-do list for stuff I need to write my own modules for.
{
imports = [ ./neofetch.nix ];
}

View File

@@ -1,114 +0,0 @@
{lib, config, self, ...}: {
options = {
homeFiles.enable = lib.mkEnableOption "enables declared custom files";
};
config = lib.mkIf config.homeFiles.enable {
home.file.".config/neofetch/config.conf".text = ''
username=$(whoami)
name_length=''${#username}
total_width=40
side_length=$(( (total_width - name_length - 2) / 2 ))
top_line=$(printf "%.0s" $(seq 1 $side_length))
top_line="$top_line $username "
top_line+=$(printf "%.0s" $(seq 1 $side_length))
if (( (total_width - name_length) % 2 != 0 )); then
top_line+=""
fi
print_info() {
prin "$top_line"
info " " distro
info " " kernel
info " " wm
info " " shell
info " " term
info " " term_font
info " 󰏗 " packages
prin ""
info cols
prin "\n \n \n \n \n ''${cl3} \n \n ''${cl5} \n \n ''${cl2} \n \n ''${cl6} \n \n ''${cl4} \n \n ''${cl1} \n \n ''${cl7} \n \n ''${cl0}"
}
kernel_shorthand="on"
distro_shorthand="on"
os_arch="off"
uptime_shorthand="on"
memory_percent="on"
package_managers="off"
shell_path="off"
shell_version="on"
speed_type="bios_limit"
speed_shorthand="on"
gtk_shorthand="on"
gtk2="on"
gtk3="on"
colors=(distro)
bold="on"
underline_enabled="on"
underline_char="-"
separator=" "
color_blocks="off"
block_range=(0 15) # Colorblocks
# Colors for custom colorblocks
magenta="\033[1;35m"
green="\033[1;32m"
white="\033[1;37m"
blue="\033[1;34m"
red="\033[1;31m"
black="\033[1;40;30m"
yellow="\033[1;33m"
cyan="\033[1;36m"
reset="\033[0m"
bgyellow="\033[1;43;33m"
bgwhite="\033[1;47;37m"
cl0="''${reset}"
cl1="''${magenta}"
cl2="''${green}"
cl3="''${white}"
cl4="''${blue}"
cl5="''${red}"
cl6="''${yellow}"
cl7="''${cyan}"
cl8="''${black}"
cl9="''${bgyellow}"
cl10="''${bgwhite}"
block_width=4
block_height=1
bar_char_elapsed="-"
bar_char_total="="
bar_border="on"
bar_length=15
bar_color_elapsed="distro"
bar_color_total="distro"
cpu_display="on"
memory_display="on"
battery_display="on"
disk_display="on"
image_backend="kitty"
image_source="${self}/assets/images/nixos-logo.png"
image_size="250px"
image_loop="off"
aascii_distro="auto"
ascii_colors=(distro)
ascii_bold="on"
crop_mode="normal"
crop_offset="center"
gap=2
yoffset=0
xoffset=0
stdout="off"
'';
};
}