use imports and split programs into their own files for organization

This commit is contained in:
= 2024-03-11 03:30:34 -05:00
parent 88107ecd41
commit a442323649
25 changed files with 850 additions and 357 deletions

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, settings, ... }:
{ config, lib, pkgs, settings, ylib, ... }:
let
home-manager = builtins.fetchTarball {
url = "https://github.com/nix-community/home-manager/archive/release-23.11.tar.gz";
@ -23,7 +23,7 @@ in
security.polkit.enable = true;
home-manager.useUserPackages = true;
home-manager.useGlobalPkgs = true;
home-manager.extraSpecialArgs = { inherit settings; };
home-manager.extraSpecialArgs = { inherit settings; inherit ylib; };
# ==========
# Common
@ -45,5 +45,55 @@ in
LC_TIME = settings.system.defaultLocale;
};
# Some basics
nixpkgs.config.allowUnfree = true;
environment.systemPackages = with pkgs; [
# Basics
neovim
vim
wget
curl
neofetch
bat
htop
nvtop
unzip
git
fzf
ripgrep
];
environment.shellAliases = {
n = "nvim";
nn = "nvim --headless '+SessionDelete' +qa > /dev/null 2>&1 && nvim";
bat = "bat --theme Coldark-Dark";
cat = "bat --pager=never -p";
nix-boot-clean = "find '/boot/loader/entries' -type f | head -n -4 | xargs -I {} rm {}; nix-collect-garbage -d; nixos-rebuild boot; echo; df";
# general unix
date_compact = "date +'%Y%m%d'";
date_short = "date +'%Y-%m-%d'";
ls = "ls --color -Ga";
ll = "ls --color -Gal";
lss = "du --max-depth=0 -h * 2>/dev/null";
psg = "ps aux | head -n 1 && ps aux | grep -v 'grep' | grep";
cl = "clear";
# git
stash = "git stash";
pop = "git stash pop";
branch = "git checkout -b";
status = "git status";
diff = "git diff";
branches = "git branch -a";
gcam = "git commit -a -m";
stashes = "git stash list";
# ripgrep
rg="rg --no-ignore";
rgf="rg --files 2>/dev/null | rg";
};
environment.shellInit = builtins.readFile ./shellInit.sh;
system.stateVersion = "23.11";
}

View file

@ -0,0 +1,131 @@
# basics
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 } }')
}
kill_psg() {
PIDS=$(ps aux | grep -v "grep" | grep ${1} | awk '{print $2}')
echo Killing ${PIDS}
for pid in ${PIDS}; do
kill -9 ${pid} &> /dev/null
done
}
term_psg() {
assert_command awk
assert_command grep
PIDS=$(ps aux | grep -v "grep" | grep ${1} | awk '{print $2}')
echo Terminating ${PIDS}
for pid in ${PIDS}; do
kill -15 ${pid} &> /dev/null
done
}
skill_psg() {
PIDS=$(ps aux | grep -v "grep" | grep ${1} | awk '{print $2}')
echo Quitting ${PIDS}
for pid in ${PIDS}; do
sudo kill -9 ${pid} &> /dev/null
done;
}
mail_clear() {
: > /var/mail/$USER
}
# git
getdefault () {
assert_command git
assert_command grep
assert_command sed
git remote show origin | grep "HEAD branch" | sed 's/.*: //'
}
master () {
assert_command git
git stash
git checkout $(getdefault)
pull
}
mp () {
master
prunel
}
pullmaster () {
assert_command git
git pull origin $(getdefault)
}
push () {
assert_command git
assert_command sed
B=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
git pull origin $B
git push origin $B --no-verify
}
pull () {
assert_command git
assert_command sed
git fetch
B=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
git pull origin $B
}
forcepush () {
assert_command git
assert_command sed
B=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
git push origin $B --force
}
remote_branches () {
assert_command git
assert_command grep
git branch -a | grep 'remotes' | grep -v -E '.*(HEAD|${DEFAULT})' | cut -d'/' -f 3-
}
local_branches () {
assert_command git
assert_command grep
assert_command cut
git branch -a | grep -v 'remotes' | grep -v -E '.*(HEAD|${DEFAULT})' | grep -v '^*' | cut -d' ' -f 3-
}
prunel () {
assert_command git
git fetch
git remote prune origin
for local in $(local_branches); do
in=false
for remote in $(remote_branches); do
if [[ ${local} = ${remote} ]]; then
in=true
fi
done;
if [[ $in = 'false' ]]; then
git branch -D ${local}
else
echo 'Skipping branch '${local}
fi
done;
}
checkout () {
assert_command git
git fetch
git checkout $1
pull
}
from_master () {
assert_command git
git checkout $(getdefault) $@
}

View file

@ -96,7 +96,10 @@ in
shell = pkgs.zsh;
};
# TODO how to do this from home manager file instead
environment.pathsToLink = [ "/share/fish" ];
environment.pathsToLink = [ "/share/zsh" ];
programs.zsh = {
enable = true;
};
home-manager.users.${settings.user.username} = homeManagerUser;
services.xserver.enable = true;
@ -108,17 +111,6 @@ in
# $ nix search wget
nixpkgs.config.allowUnfree = true;
environment.systemPackages = with pkgs; [
# Basics
neovim
vim
wget
curl
neofetch
bat
htop
nvtop
unzip
git
# [Laptop] Battery status
acpi
# extras, more for my neovim setup TODO move these into a more isolated place for nvim setup? Should be its own flake probably
@ -126,23 +118,13 @@ in
rustc
nodejs_21
python313
ripgrep
# ripgrep # now in common
nodePackages.cspell
#
fzf
];
programs.zsh = {
enable = true;
};
# does for all shells. Can use `programs.zsh.shellAliases` for specific ones
environment.shellAliases = {
n = "nvim";
battery = "acpi";
wifi = "nmtui";
bat = "bat --theme Coldark-Dark";
cat = "bat --pager=never -p";
nix-boot-clean = "find '/boot/loader/entries' -type f | head -n -4 | xargs -I {} rm {}; nix-collect-garbage -d; nixos-rebuild boot; echo; df";
};
}