mlaga97-nix/home-manager/programs/bash.nix
2025-08-12 23:40:55 -05:00

45 lines
1.2 KiB
Nix

{ self, ... }: let
rev = builtins.replaceStrings ["-dirty"] ["*"] (toString (self.shortRev or self.dirtyShortRev or self.lastModified or "unknown"));
in {
programs.bash = {
enable = true;
shellAliases = {
ssh-with-yubikey = "ssh_with_yubikey";
};
bashrcExtra = ''
# Load Default .bashrc if non-NixOS
if [ -e "/etc/skel/.bashrc" ]; then
source /etc/skel/.bashrc
fi
# Helper Functions
ssh_with_yubikey () { AGENT_SOCKET=$(ssh $@ gpgconf --list-dirs agent-socket) && ssh -A -R "$AGENT_SOCKET:$(gpgconf --list-dirs agent-socket)" -o "StreamLocalBindUnlink=yes" $@; }
case "$(sed -n 's|^NAME=||p' /etc/os-release)" in
"NixOS")
DISTRO_SYMBOL=""
;;
"Ubuntu"|'"Ubuntu"')
DISTRO_SYMBOL=""
;;
"Alpine Linux")
DISTRO_SYMBOL=""
;;
"Arch Linux")
DISTRO_SYMBOL=""
;;
"CentOS Linux")
DISTRO_SYMBOL=""
;;
"Fedora")
DISTRO_SYMBOL=""
;;
*)
DISTRO_SYMBOL=""
;;
esac
export SYSTEM_GIT_REV="$DISTRO_SYMBOL ${rev}"
'';
};
}