# _                                  _
#| |__   ___  _ __ ___   ___   _ __ (_)_  __
#| '_ \ / _ \| '_ ` _ \ / _ \ | '_ \| \ \/ /
#| | | | (_) | | | | | |  __/_| | | | |>  <
#|_| |_|\___/|_| |_| |_|\___(_)_| |_|_/_/\_\
#Coast's ~/.config/home-manager/home.nix
{ config, pkgs, ... }:
{
  home.username = "avery";
  home.homeDirectory = "/home/avery";
  home.stateVersion = "25.05";
  home.packages = with pkgs; [
    bat cowsay bat cmatrix bat cava cbonsai bat ksh bat tree hyfetch qutebrowser xonsh elvish openjdk btop htop cpufetch lm_sensors dysk dogdns ];
  home.file = {
  };
  home.sessionVariables = {
    EDITOR = "emacs";
    BROWSER = "brave";
  };
  programs.eza = {
    enable = true;
};
  programs.bash = {
    enable = true;
    initExtra = ''
      if [ "$(id -u)" = 0 ]; then PS1ICON='#'; else PS1ICON='$'; fi
PS1='\[\e[38;2;254;128;25m\][\[\e[38;2;235;219;178m\]\u\[\e[38;2;200;200;200m\]@\[\e[38;2;131;165;152m\]coast \[\e[38;2;235;219;178m\]\w\[\e[38;2;254;128;25m\]]'"$PS1ICON"'\[\e[0m\] '
    source "$HOME/.config/shell/aliases"
    source "$HOME/.config/shell/exports"
    '';
};
  home.file.".config/bat/config".text = ''
    --theme="Nord"
    --style="numbers,changes,grid"
    --paging=auto
  '';
#vim conf
  home.file.".vimrc".text = ''
    set number
    set shiftwidth=4
    set tabstop=4
    set wrap
    set cursorline
    set linebreak
    set termguicolors
    syntax on
    filetype plugin indent on
    set ignorecase
    set smartcase
    set hlsearch
    set incsearch
    set autoindent
    set expandtab
    map <F^> :setlocal spell! spelllang=en_us<CR>
    nnoremap <C-n> :NERDTreeToggle<CR>
    call plug#begin('~/.vim/plugged')
    Plug 'tpope/vim-sensible'
    Plug 'preservim/nerdtree'
    Plug 'junegunn/fzf', { 'do': { -> fzf#install() }  }
    Plug 'junegunn/fzf.vim'
    Plug 'vim-airline/vim-airline'
    Plug 'vim-airline/vim-airline-themes'
    call plug#end()
    set background=dark
  '';
  home.file.".config/shell/exports".text = ''
    export PATH=$HOME/.local/bin:$PATH
    export PATH=$HOME/.luarocks/bin:$PATH
    if [ -n "$ZSH_VERSION"  ]; then 
        export ZSH="/home/avery/.oh-my-zsh"
    fi
    export NIXPKGS_ALLOW_UNFREE=1
    export EDITOR="emacs"
  '';
  home.file.".config/shell/aliases".text = '' 
    #!/bin/sh
    #general aliases
    alias xi="doas xbps-install -S $1"
    alias nf="clear && fastfetch"
    alias ascdis="fastfetch --logo $1"
    alias forge="su forgejo"
    alias emoji="cat ~/.local/share/emoji | grep $1"
    alias cst="emacs ~/.suckless/st/config.h"
    alias las="ls"
    alias lasa="ls -a"
    alias lasal="ls -al"
    alias anal="ls -ahl"
    alias resmacs="systemctl --user restart emacsd"
    alias smi="nvidia-smi"
    alias src="source ~/.zshrc"
    alias bat="sb-battery"
    alias battery="sb-battery"
    alias vimrc="vim .vimrc"
    alias ri="ranger"
    alias rim="ranger"
    alias quit="exit"
    alias :q="exit"
    alias :q!="exit"
    alias :Q="exit"
    alias :Q!="exit"
    alias :quit="exit"
    alias :quit!="exit"
    alias :QUIT="exit"
    alias :QUIT!="exit"
    alias q="exit"
    alias fnl="fennel"
    alias "push"="git push -u origin main"
    alias irc="irssi"
    alias hsw="home-manager switch --flake ~/.config/home-manager"
    alias hsc="emacs ~/.config/home-manager/home.nix"
    alias yell="echo"
    alias chm="ecop cat ~/.config/home-manager/home.nix"
    if [ -n "$ZSH_VERSION"  ]; then
        alias ed="ed -p '%: '"
    else
        alias ed="ed -p '$: '"
    fi
    alias weather="curl wttr.in/masjedsoleyman"
    #typo/shortcut
    alias c="clear"
    alias cear="clear"
    alias "cd.."="cd .."
    alias claer="clear"
    alias claer="clear"
    alias clare="clear"
    alias cleae="clear"
    alias clera="clear"
    alias hotp="htop"
  '';
  home.file.".zshrc".text = ''
  #!/usr/bin/zsh
  HISTFILE=$HOME/.cache/zsh/history
  SAVEHIST=100000000
  HISTSIZE=$SAVEHIST
  setopt appendhistory
  #tab completion
  autoload -U compinit
  zstyle ':completion:*' menu select
  zmodload zsh/complist
  compinit
  _comp_options+=(globdots)
  #oh my zsh
  ZSH_THEME="gentoo"
  plugins=(git)
  export ZSH="$HOME/.oh-my-zsh"
  source $ZSH/oh-my-zsh.sh
  #eval
  eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
  #source
  source "$HOME/.config/shell/aliases"
  source "$HOME/.config/shell/exports"
  source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
  fpath=(/usr/share/zsh/site-functions $fpath)
  source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
  #colors
  autoload -U colors && colors
  setopt prompt_subst
  #prompt
  [ "$(id -u)" = 0 ] && PS1ICON="#" || PS1ICON='%'
  PROMPT='%{$(echo -e "\e[38;2;254;128;25m")%}[%{$(echo -e "\e[38;2;235;219;178m")%}%n%{$(echo -e "\e[38;2;200;200;200m")%}@%{$(echo -e "\e[38;2;131;165;152m")%}coast %{$(echo -e "\e[38;2;235;219;178m")%}%~%{$(echo -e "\e[38;2;254;128;25m")%}]%$PS1ICON%{$(echo -e "\e[0m")%} '
  '';

    programs.alacritty = {
    enable = true;
    settings = {
      window = {
        padding = {
          x = 4;
          y = 4;
        };
        decorations = "transparent";
        blur = true;
        opacity = 0.9;
      };
      font = {
        normal = {
          family = "monospace";
        };
        size = 9;
      };
      colors = {
#        primary = {
#          background = "0x1e1e2e";
#          foreground = "0xcdd6f4";
#        };
        cursor = {
          text = "0x1e1e2e";
          cursor = "0xcdd6f4";
        };
      };
    };
  };

  programs.home-manager.enable = true;
}
