nixos/apps/fastfetch.nix

110 lines
3.1 KiB
Nix
Raw Normal View History

2025-12-03 19:53:58 +00:00
{ config, pkgs, ... }:
{
2025-12-21 13:42:38 +00:00
# Install fastfetch, ghostty, and nerd fonts
2025-12-03 19:53:58 +00:00
environment.systemPackages = with pkgs; [
fastfetch
];
2025-12-03 20:29:05 +00:00
# Install Nerd Fonts for icon support
fonts.packages = with pkgs; [
2025-12-03 20:29:57 +00:00
nerd-fonts.fira-code
nerd-fonts.jetbrains-mono
nerd-fonts.meslo-lg
2025-12-03 20:29:05 +00:00
];
2025-12-20 22:37:20 +00:00
# Create the fastfetch config file with custom image
2025-12-03 19:53:58 +00:00
environment.etc."fastfetch/config.jsonc".text = ''
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
2025-12-21 12:16:53 +00:00
"logo": {
"source": "none"
},
2025-12-03 19:53:58 +00:00
"display": {
2025-12-03 20:22:36 +00:00
"separator": " ",
2025-12-03 19:53:58 +00:00
"color": {
"keys": "blue",
"title": "cyan"
2025-12-03 20:58:54 +00:00
},
"key": {
"type": "icon"
2025-12-03 19:53:58 +00:00
}
},
"modules": [
{
2025-12-21 14:05:34 +00:00
"type": "command",
"text": "echo $(whoami)@$(hostname) $(uname -r)"
2025-12-03 19:53:58 +00:00
},
{
"type": "colors",
"symbol": "circle"
}
]
}
'';
2025-12-03 20:22:36 +00:00
# Set up bash with fastfetch and a nice prompt
2025-12-03 20:29:05 +00:00
programs.bash.promptInit = ''
2025-12-21 14:11:48 +00:00
# Powerline-style prompt with background colors
# Powerline separator
SEP=""
2025-12-21 14:13:58 +00:00
# Background colors
BG_BLUE="$(echo -e '\033[48;5;33m')"
BG_PURPLE="$(echo -e '\033[48;5;98m')"
BG_GREEN="$(echo -e '\033[48;5;35m')"
BG_CYAN="$(echo -e '\033[48;5;37m')"
2025-12-21 14:11:48 +00:00
# Foreground colors for separators
2025-12-21 14:13:58 +00:00
FG_BLUE="$(echo -e '\033[38;5;33m')"
FG_PURPLE="$(echo -e '\033[38;5;98m')"
FG_GREEN="$(echo -e '\033[38;5;35m')"
FG_CYAN="$(echo -e '\033[38;5;37m')"
# White text and reset
WHITE="$(echo -e '\033[97m')"
RESET="$(echo -e '\033[0m')"
2025-12-21 14:11:48 +00:00
2025-12-21 14:13:58 +00:00
# Function to build path with colored segments
build_path_prompt() {
local path="''${PWD/#$HOME/~}"
local IFS='/'
local parts=($path)
local output=""
local colors=("''${BG_GREEN}" "''${BG_CYAN}" "''${BG_BLUE}")
local fg_colors=("''${FG_GREEN}" "''${FG_CYAN}" "''${FG_BLUE}")
local i=0
for part in "''${parts[@]}"; do
local color_idx=$((i % 3))
local next_color_idx=$(((i + 1) % 3))
if [ -n "$part" ]; then
output+="''${colors[$color_idx]}''${WHITE} $part "
if [ $i -lt $((''${#parts[@]} - 1)) ]; then
output+="''${colors[$next_color_idx]}''${fg_colors[$color_idx]}''${SEP}"
fi
((i++))
fi
done
echo -n "$output"
}
2025-12-03 20:22:36 +00:00
# Function to get git branch
parse_git_branch() {
2025-12-21 14:11:48 +00:00
local branch=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
if [ -n "$branch" ]; then
2025-12-21 14:13:58 +00:00
echo -n "''${BG_PURPLE}''${FG_CYAN}''${SEP}''${BG_PURPLE}''${WHITE} $branch ''${RESET}''${FG_PURPLE}''${SEP}"
2025-12-21 14:11:48 +00:00
else
2025-12-21 14:13:58 +00:00
echo -n "''${RESET}''${FG_BLUE}''${SEP}"
2025-12-21 14:11:48 +00:00
fi
2025-12-03 20:22:36 +00:00
}
2025-12-21 14:13:58 +00:00
# Set prompt command to rebuild on each prompt
PROMPT_COMMAND='PS1="$(build_path_prompt)$(parse_git_branch)''${RESET} "'
2025-12-03 19:53:58 +00:00
'';
2025-12-03 20:29:05 +00:00
programs.bash.interactiveShellInit = ''
2025-12-03 21:29:18 +00:00
# Run fastfetch on terminal start
2025-12-03 20:29:05 +00:00
if [[ $- == *i* ]]; then
2025-12-03 21:29:18 +00:00
${pkgs.fastfetch}/bin/fastfetch --config /etc/fastfetch/config.jsonc
2025-12-03 20:29:05 +00:00
fi
'';
2025-12-03 19:53:58 +00:00
}