Files
nix-dotfiles-v2/home/bash.nix
2025-12-02 10:43:45 +01:00

96 lines
2.5 KiB
Nix

{
pkgs,
lib,
config,
inputs,
...
}:
{
sops.secrets = {
"ai/openai" = { };
"ai/openrouter" = { };
"ai/fireworks" = { };
"ai/cerebras" = { };
"ai/groq" = { };
"ai/mistral" = { };
};
programs.bash = {
enable = true;
shellAliases = {
"rebuild" =
"sudo nixos-rebuild switch --no-write-lock-file --flake git+https://github.com/adrlau/nix-dotfiles.git -L --impure";
"," = "comma ";
"gst" = "git status";
"gsw" = "git switch";
"gcm" = "git commit -m ";
"gca" = "git commit --amend";
"gaa" = "git add -A";
"gb" = "git branch";
"rm" = "rm -i"; # help me awoid accidental removals.
"cim" = "neovim";
"sl" = "eza";
"ls" = "eza";
"lls" = "ls";
"la" = "eza -la";
"tree" = "eza -T";
"neofetch" = "fastfetch";
"htop" = "btm";
};
bashrcExtra = ''
# Export AI API keys from decrypted sops-nix secrets
export OPENAI_API_KEY="$(cat ${config.sops.secrets."ai/openai".path})"
export OPENROUTER_API_KEY="$(cat ${config.sops.secrets."ai/openrouter".path})"
export FIREWORKS_API_KEY="$(cat ${config.sops.secrets."ai/fireworks".path})"
export CEREBRAS_API_KEY="$(cat ${config.sops.secrets."ai/cerebras".path})"
export GROQ_API_KEY="$(cat ${config.sops.secrets."ai/groq".path})"
export MISTRAL_API_KEY="$(cat ${config.sops.secrets."ai/mistral".path})"
#PS1 section
RESET='\[\e[0m\]'
BOLD='\[\e[1m\]'
CYAN='\[\e[36m\]'
GREEN='\[\e[32m\]'
BLUE='\[\e[34m\]'
YELLOW='\[\e[33m\]'
MAGENTA='\[\e[35m\]'
RED='\[\e[31m\]'
if [[ -n "$SSH_CONNECTION" ]]; then
REMOTE_LABEL="\[''${YELLOW}\] (ssh)\[''${RESET}\]"
else
REMOTE_LABEL=""
fi
# Git branch function
parse_git_branch() {
git branch --show-current 2>/dev/null | awk '{print " (" $1 ")"}'
}
# Set prompt
if [[ $EUID -eq 0 ]]; then
PS1="''${BOLD}''${RED}\u''${RESET}:''${BOLD}''${RED}\h''${REMOTE_LABEL}''${RESET}:''${BOLD}''${GREEN}\w''${MAGENTA}\$(parse_git_branch) ''${BLUE}\A''${RESET}\$ "
else
PS1="''${BOLD}''${CYAN}\u''${RESET}:''${BOLD}''${CYAN}\h''${REMOTE_LABEL}''${RESET}:''${BOLD}''${GREEN}\w''${MAGENTA}\$(parse_git_branch) ''${BLUE}\A''${RESET}\$ "
fi
'';
historyControl = [
"ignoredups"
"ignorespace"
"erasedups"
];
historyIgnore = [
"ls"
"cd"
"exit"
"cd .."
".."
"la"
];
};
}