refactoring to more granular flakes and modules

This commit is contained in:
RingOfStorms (Joshua Bell) 2025-10-21 22:12:23 -05:00
parent 6570da6f33
commit 50825c9b84
52 changed files with 2501 additions and 9 deletions

View file

@ -0,0 +1,55 @@
{
lib,
pkgs,
...
}:
with lib;
{
environment.systemPackages = with pkgs; [
# Essentials
vim
nano
wget
curl
traceroute
dig
fastfetch
jq
bat
htop
unzip
fzf
ripgrep
lsof
killall
speedtest-cli
];
environment.shellAliases = {
n = "nvim";
nn = "nvim --headless '+SessionDelete' +qa > /dev/null 2>&1 && nvim";
bat = "bat --theme Coldark-Dark";
cat = "bat --pager=never -p";
# TODO this may not be needed now that I am using `nh` clean mode (see /hosts/_common/configuration.nix#programs.nh)
nix-boot-clean = "find '/boot/loader/entries' -type f ! -name 'windows.conf' | head -n -4 | xargs -I {} rm {}; nix store gc; nixos-rebuild boot; echo; df";
ndr = "nix-direnv-reload";
# general unix
date_compact = "date +'%Y%m%d'";
date_short = "date +'%Y-%m-%d'";
ls = "ls --color -Gah";
ll = "ls --color -Galhtr";
lss = "du --max-depth=0 -h {.,}* 2>/dev/null | sort -hr";
psg = "ps aux | head -n 1 && ps aux | grep -v 'grep' | grep";
# ripgrep
rg = "rg --no-ignore";
rgf = "rg --files --glob '!/nix/store/**' 2>/dev/null | rg";
};
environment.shellInit = lib.concatStringsSep "\n\n" [
(builtins.readFile ./unix_utils.func.sh)
(builtins.readFile ./nixpkg.func.sh)
];
}

View file

@ -0,0 +1,13 @@
# nix
alias nixpkgs=nixpkg
nixpkg () {
if [ $# -eq 0 ]; then
echo "Error: No arguments provided. Please specify at least one package."
return 1
fi
cmd="nix shell"
for pkg in "$@"; do
cmd="$cmd \"nixpkgs#$pkg\""
done
eval $cmd
}

View file

@ -0,0 +1,65 @@
# Check if ~/.config/environment exists and source all files within it
if [ -d "$HOME/.config/environment" ]; then
for file in "$HOME/.config/environment/"*; do
if [ -r "$file" ]; then
if ! . "$file"; then
echo "Failed to source $file"
fi
fi
done
fi
htop_psg () {
htop -p $(psg $1 | awk '{r=r s $2;s=","} END{print r}')
}
htop_pid () {
htop -p $(ps -ef | awk -v proc=$1 '$3 == proc { cnt++;if (cnt == 1) { printf "%s",$2 } else { printf ",%s",$2 } }')
}
psg_kill() {
ps aux | grep -v "grep" | grep "${1}" | awk '{print $2}' | while read -r pid; do
if [ -n "${pid}" ]; then
echo "killing ${pid}"
kill -9 "${pid}" &> /dev/null
fi
done
}
psg_terminate() {
ps aux | grep -v "grep" | grep "${1}" | awk '{print $2}' | while read -r pid; do
if [ -n "${pid}" ]; then
echo "Terminating ${pid}"
kill -15 "${pid}" &> /dev/null
fi
done
}
psg_skill() {
ps aux | grep -v "grep" | grep "${1}" | awk '{print $2}' | while read -r pid; do
if [ -n "${pid}" ]; then
echo "Killing ${pid}"
sudo kill -9 "${pid}" &> /dev/null
fi
done
}
mail_clear() {
: > /var/mail/$USER
}
speedtest_fs () {
dir=$(pwd)
drive=$(df -h ${dir} | awk 'NR==2 {print $1}')
echo Testing read speeds on drive ${drive}
sudo hdparm -Tt ${drive}
test_file=$(date +%u%m%d)
test_file="${dir}/speedtest_fs_${test_file}"
echo
echo Testing write speeds into test file: ${test_file}
dd if=/dev/zero of=${test_file} bs=8k count=10k; rm -f ${test_file}
}
speedtest_internet () {
speedtest-cli
}