Refactor the entire configuration

With the release of the Nvidia 555 beta drivers and their improvements to
the Wayland experience I've finally decided to return to NixOS with
Hyprland again after 2 years of running Gentoo and Opensuse Tumbleweed
on X11. So this is me committing the work done so far from the last
couple of days. Future commits will be more incremental.
This commit is contained in:
caem 2024-05-24 21:33:00 +02:00
parent 97c86fb014
commit 75b13ac379
Signed by: caem
GPG key ID: 69A830D03203405F
72 changed files with 2045 additions and 196 deletions

View file

@ -0,0 +1,12 @@
#!/usr/bin/env zsh
# Prefetch paths
source "$ZDOTDIR/conf.d/path.zsh"
for file in $ZDOTDIR/conf.d/*; do
if [[ "$file" == *"path.zsh" ]]; then
continue
fi
source "$file"
done

View file

@ -0,0 +1,4 @@
#!/usr/bin/env zsh
alias reload="exec zsh"

View file

@ -0,0 +1,11 @@
#!/usr/bin/env zsh
alias ls='ls --color=auto'
alias ll='ls -lah --color=auto'
alias grep='grep --color=auto'
term_name=$(ps -o comm= "$PPID")
if [ "$term_name" = "xterm" ] && [ -n "$(command -v "transset")" ]; then
transset -a 0.95 > /dev/null
fi

View file

@ -0,0 +1,18 @@
#!/usr/bin/env zsh
if [ -z "$FZF_TAB_FILE" ] && [ ! -d "$HOME/.cache/fzf-tab" ]; then
echo "Installing fzf-tab"
git clone "https://github.com/Aloxaf/fzf-tab" "$HOME/.cache/fzf-tab"
FZF_TAB_FILE="$HOME/.cache/fzf-tab/fzf-tab.plugin.zsh"
fi
autoload -Uz compinit
compinit
source "$FZF_TAB_FILE"
zstyle ':completion:*:git-checkout:*' sort false
if [ -n "$TMUX" ]; then
zstyle ':fzf-tab:*' fzf-command ftb-tmux-popup
fi

View file

@ -0,0 +1,6 @@
#!/usr/bin/env zsh
if [ -n "$(command -v qt5ct)" ] && [ -z "$DESKTOP_SESSION" ]; then
export QT_QPA_PLATFORMTHEME=qt5ct
fi

View file

@ -0,0 +1,9 @@
#!/usr/bin/env zsh
if [ -n "$(command -v thefuck)" ]; then
fuck() {
eval $(thefuck --alias)
fuck
}
fi

View file

@ -0,0 +1,5 @@
#!/usr/bin/env zsh
GPG_TTY=$(tty)
export GPG_TTY

View file

@ -0,0 +1,6 @@
#!/usr/bin/env zsh
if [ -n "$(command -v "nvim")" ]; then
export MANPAGER='nvim +Man!'
fi

View file

@ -0,0 +1,46 @@
#!/usr/bin/env zsh
add_to_path() {
if [ -d "$1" ] && [[ "$PATH" != *"$1"* ]]; then
PATH="$PATH:$1"
fi
}
add_to_path "$HOME/.local/bin"
# Language package mangers
if [ -n "$(command -v go)" ]; then
export GOPATH="$HOME/.local/share/go"
add_to_path "$HOME/.local/share/go/bin"
fi
if [ -n "$(command -v npm)" ]; then
if [ -f "$HOME/.npmrc" ]; then
if [ -z "$(grep prefix "$HOME/.npmrc")" ]; then
npm config set prefix "$HOME/.local/share/npm"
fi
else
npm config set prefix "$HOME/.local/share/npm"
fi
add_to_path "$HOME/.local/share/npm/bin"
fi
if [ -n "$(command -v cargo)" ]; then
export CARGO_HOME="$HOME/.local/share/cargo"
add_to_path "$HOME/.local/share/cargo/bin"
fi
if [ -n "$(command -v pip3)" ] && [ -n "$(command -v virtualenv)" ]; then
if [ ! -d "$HOME/.local/share/python3-venv" ]; then
python3 -m venv "$HOME/.local/share/python3-venv"
fi
if [ "$(grep "executable" "$HOME/.local/share/python3-venv/pyvenv.cfg" | awk '{print $3}')" \
!= "$(realpath $(command -v python3))" ]; then
python3 -m venv --upgrade "$HOME/.local/share/python3-venv"
fi
export VIRTUAL_ENV_DISABLE_PROMPT=true
source "$HOME/.local/share/python3-venv/bin/activate"
fi

View file

@ -0,0 +1,18 @@
#!/usr/bin/env zsh
distro=$(cat /etc/os-release | grep -w 'ID=.*' | sed -e 's/ID=//g' | awk '{print $1}')
case "$distro" in
"debian") dicon="%F{red}%f" ;;
"gentoo") dicon="%F{magenta}%f" ;;
"\"opensuse-tumbleweed\"") dicon="%F{green} %f" ;;
"nixos") dicon="%F{cyan}%f" ;;
*) dicon="%F{yellow}[󰘧]%f" ;;
esac
setopt prompt_subst
autoload -Uz vcs_info
precmd () { vcs_info }
zstyle ':vcs_info:*' formats ' %F{yellow}(%b)%f'
export PS1='$dicon %n@%m %F{green}%~%f$vcs_info_msg_0_> '

View file

@ -0,0 +1,11 @@
#!/usr/bin/env zsh
if [ -z "$DESKTOP_SESSION" ]; then
if [ -z "$(pidof gnome-keyring-daemon)" ] && [ -n "$(command -v gnome-keyring-daemon)" ]; then
{ eval $(gnome-keyring-daemon --start); } > /dev/null 2>&1
export SSH_AUTH_SOCK
else
{ eval $(ssh-agent -s); } > /dev/null 2>&1
fi
fi

View file

@ -0,0 +1,29 @@
#!/usr/bin/env zsh
export HISTFILE=~/.cache/zsh_history
export HISTSIZE=10000
export SAVEHIST=$HISTSIZE
setopt INC_APPEND_HISTORY
setopt SHARE_HISTORY
setopt HIST_IGNORE_SPACE
setopt HIST_SAVE_NO_DUPS
if [ -z "$AUTOSUGGEST_FILE" ]; then
import_file="/usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh"
else
import_file="$AUTOSUGGEST_FILE"
fi
if [ ! -f "$import_file" ]; then
if [ ! -d "$HOME/.cache/zsh-autosuggestions" ]; then
echo "Installing zsh-autosuggestions..."
git clone "https://github.com/zsh-users/zsh-autosuggestions.git" "$HOME/.cache/zsh-autosuggestions"
fi
import_file="$HOME/.cache/zsh-autosuggestions/zsh-autosuggestions.zsh"
fi
source "$import_file"
ZSH_AUTOSUGGEST_STRATEGY=(history completion)

View file

@ -0,0 +1,18 @@
#!/usr/bin/env zsh
if [ -z "$SYNTAX_FILE" ]; then
import_file="/usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
else
import_file="$SYNTAX_FILE"
fi
if [ ! -f "$import_file" ]; then
if [ ! -d "$HOME/.cache/zsh-syntax-highlighting" ]; then
echo "Installing zsh-syntax-highlighting..."
git clone "https://github.com/zsh-users/zsh-syntax-highlighting.git" "$HOME/.cache/zsh-syntax-highlighting"
fi
import_file="$HOME/.cache/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
fi
source "$import_file"

View file

@ -0,0 +1,9 @@
#!/usr/bin/env zsh
# Disabled until I fix my tmux config
return
if [ "$TERM" = "xterm-256color" ] && [ -x "$(command -v tmux)" ]; then
tmux new-session
fi

View file

@ -0,0 +1,17 @@
{ pkgs, ... }:
{
home.file."/home/hu/.config/zsh/conf.d" = {
source = ./config/conf.d;
recursive = true;
};
home.file."/home/hu/.config/zsh/.zshrc" = {
text = ''
#!/usr/bin/env zsh
SYNTAX_FILE="${pkgs.zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
FZF_TAB_FILE="${pkgs.zsh-fzf-tab}/share/fzf-tab/fzf-tab.plugin.zsh"
AUTOSUGGEST_FILE="${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh"
'' + (builtins.readFile config/.zshrc);
};
}

View file

@ -0,0 +1,19 @@
{ config, pkgs, ... }:
{
programs.zsh.enable = true;
environment.variables = {
ZDOTDIR = "${config.users.users.hu.home}/.config/zsh";
};
environment.systemPackages = with pkgs; [
fzf
zsh-fzf-tab
zsh-completions
zsh-autosuggestions
zsh-syntax-highlighting
nix-zsh-completions
thefuck
];
}