Files
NixOS-Configs/home/zsh/init.zsh
Anish Govind 598a43eace refactor: make hosts declarative and consolidate shared config
- add my.username / my.gaming.enable / my.ai.local.enable options and
  gate optional app modules on them instead of per-host import lists
- move vendor-neutral hardware.graphics into modules/graphical, leaving
  only NVIDIA-specific drivers and env vars in modules/hardware/nvidia
- derive the primary user everywhere from my.username (users, getty,
  home-manager, tmpfiles)
- de-duplicate Hyprland autostart down to a single system loginShellInit
  using the start-hyprland wrapper
- consolidate all nixpkgs overlays into modules/core/nix.nix and use
  final.stdenv.hostPlatform.system
- make the zsh rebuild helper target $(hostname) instead of hardcoded hades
- add nixpkgs follows for nixos-hardware, pi and comfy-ui (single nixpkgs)
- add .gitignore and a nixfmt flake formatter; format all nix files
- remove empty browser.nix/display-configuration.nix and rename
  local_ai.nix -> local-ai.nix
- document the my.* toggles in the README
2026-09-18 23:32:32 -07:00

121 lines
4.1 KiB
Bash

# Path configuration
export PATH="$HOME/.local/bin:$HOME/bin:$HOME/.cargo/bin:$PNPM_HOME:$PATH"
if [ -d "$HOME/Tools/xilinx/Vivado/2023.1/bin" ]; then
export PATH="$HOME/Tools/xilinx/Vivado/2023.1/bin:$PATH"
fi
# Miniconda / conda profile hook if installed
if [ -f /opt/miniconda3/etc/profile.d/conda.sh ]; then
source /opt/miniconda3/etc/profile.d/conda.sh
fi
# Environment modules support if available
if (( ${+functions[module]} )) || [ -f /etc/modules/init/zsh ]; then
[ -f /etc/modules/init/zsh ] && source /etc/modules/init/zsh
module use --append "$HOME/.config/modulefiles" 2>/dev/null || true
fi
# Auto-tmux configuration
use_auto_tmux () {
! ([ -z "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ] || $(pgrep -x "i3" > /dev/null || pgrep -x "sway" > /dev/null || pgrep -x "Hyprland" > /dev/null))
}
if use_auto_tmux; then
export ZSH_TMUX_AUTOSTART=true
export ZSH_TMUX_AUTOCONNECT=false
export ZSH_TMUX_AUTOQUIT=true
else
export ZSH_TMUX_AUTOSTART=false
export ZSH_TMUX_AUTOCONNECT=false
export ZSH_TMUX_AUTOQUIT=false
fi
if [[ -n "$TMUX" ]]; then
tmux-window-name() {
if [ -n "$TMUX_PLUGIN_MANAGER_PATH" ] && [ -f "$TMUX_PLUGIN_MANAGER_PATH/tmux-window-name/scripts/rename_session_windows.py" ]; then
("$TMUX_PLUGIN_MANAGER_PATH/tmux-window-name/scripts/rename_session_windows.py" &)
fi
}
autoload -Uz add-zsh-hook
add-zsh-hook chpwd tmux-window-name
fi
# Custom helper functions
rebuild () {
local action="${1:-switch}"
shift 2>/dev/null || true
local config_dir="${FLAKE_CONFIG:-$HOME/NixOS-Configs}"
local host="${REBUILD_HOST:-$(hostname)}"
local target="$config_dir#$host"
case "$action" in
switch|test|boot)
echo "==> Running: sudo nixos-rebuild $action --flake $target $*"
sudo nixos-rebuild "$action" --flake "$target" "$@"
;;
build|dry-build|dry-run|dry-activate)
local act="$action"
[[ "$action" == "dry-run" ]] && act="dry-build"
echo "==> Running: nixos-rebuild $act --flake $target $*"
nixos-rebuild "$act" --flake "$target" "$@"
;;
help|-h|--help)
echo "Usage: rebuild [switch|test|boot|build|dry-build] [extra nixos-rebuild options]"
echo ""
echo "Commands:"
echo " switch Build, activate, and make default boot entry (default)"
echo " test Build and activate without creating a boot entry"
echo " boot Build and make default boot entry without activating"
echo " build Build system to ./result without activating or sudo"
echo " dry-build Show what would be built/fetched"
;;
*)
echo "==> Running: sudo nixos-rebuild $action --flake $target $*"
sudo nixos-rebuild "$action" --flake "$target" "$@"
;;
esac
}
perlmutter_pass () {
echo -n 'bw master password: '
read -s MASTER_PASS
echo
echo -n 'Copying passkey...'
echo "$(echo "$MASTER_PASS" | bw get password iris.nersc.gov 2>/dev/null)$(echo "$MASTER_PASS" | bw get totp iris.nersc.gov 2>/dev/null)" | wl-copy
echo 'Done.'
}
compiler_explorer () {
docker run -d -p 10240:10240 --name compiler-explorer madduci/docker-compiler-explorer
}
airplay_server () {
uxplay -p 10000 -nh -n "$(hostname)" -restrict -allow 88:66:5A:76:32:F5 -allow C4:AC:AA:76:B7:80
}
zathura_md () {
cat "$1" | pandoc -f markdown -t pdf | zathura -
}
fooocus () {
if [ -f "$HOME/Tools/Fooocus/entry_with_update.py" ]; then
"$HOME/.conda/envs/fooocus/bin/python" "$HOME/Tools/Fooocus/entry_with_update.py"
else
echo "Fooocus not found at $HOME/Tools/Fooocus"
fi
}
# Per-host / system local overrides fallback
if [ -f "$HOME/.config/zsh/$(hostname)/env.sh" ]; then
source "$HOME/.config/zsh/$(hostname)/env.sh"
elif [ -f "$HOME/.zshrc.local" ]; then
source "$HOME/.zshrc.local"
fi
# Fetch / Banner on interactive terminal start
if [[ -o interactive ]] && [ -z "$TMUX" ] && command -v pfetch >/dev/null 2>&1; then
pfetch
fi