diff --git a/install.sh b/install.sh index 0299e8f..905e764 100755 --- a/install.sh +++ b/install.sh @@ -12,143 +12,174 @@ DO_INSTALL=false CONFIRM_MODE=true # only true when no args are passed usage() { - echo "Usage: $0 [-l] [-i]" - echo " -l Only create symlinks (no confirmation)" - echo " -i Only install system packages (no confirmation)" - echo " (no args = do both, with confirmation)" - exit 1 + echo "Usage: $0 [-l] [-i]" + echo " -l Only create symlinks (no confirmation)" + echo " -i Only install system packages (no confirmation)" + echo " (no args = do both, with confirmation)" + exit 1 } if [ $# -eq 0 ]; then - DO_LINKS=true - DO_INSTALL=true - CONFIRM_MODE=true + DO_LINKS=true + DO_INSTALL=true + CONFIRM_MODE=true else - CONFIRM_MODE=false - while getopts ":lih" opt; do - case $opt in - l) DO_LINKS=true ;; - i) DO_INSTALL=true ;; - h) usage ;; - *) usage ;; - esac - done + CONFIRM_MODE=false + while getopts ":lih" opt; do + case $opt in + l) DO_LINKS=true ;; + i) DO_INSTALL=true ;; + h) usage ;; + *) usage ;; + esac + done fi # --------------------------------------------------------------------------------- ## Helper function for linking # --------------------------------------------------------------------------------- link_file() { - local src="$1" - local dest="$2" + local src="$1" + local dest="$2" - if [ -L "$dest" ]; then - if [ "$(readlink "$dest")" == "$src" ]; then - echo "โœ… Symlink already correct: $dest โ†’ $src" - ((SKIPPED++)) - else - echo "โš ๏ธ $dest is a symlink but points to the wrong target." - echo " Replacing with correct symlink..." - rm "$dest" - ln -s "$src" "$dest" - echo "๐Ÿ” Fixed: $dest โ†’ $src" - ((CREATED++)) - fi - elif [ -e "$dest" ]; then - echo "โš ๏ธ $dest exists but is not a symlink. Skipping." - ((SKIPPED++)) - else - mkdir -p "$(dirname "$dest")" - ln -s "$src" "$dest" - echo "โœ… Linked: $dest โ†’ $src" - ((CREATED++)) - fi + if [ -L "$dest" ]; then + if [ "$(readlink "$dest")" == "$src" ]; then + echo "โœ… Symlink already correct: $dest โ†’ $src" + ((SKIPPED++)) + else + echo "โš ๏ธ $dest is a symlink but points to the wrong target." + echo " Replacing with correct symlink..." + rm "$dest" + ln -s "$src" "$dest" + echo "๐Ÿ” Fixed: $dest โ†’ $src" + ((CREATED++)) + fi + elif [ -e "$dest" ]; then + echo "โš ๏ธ $dest exists but is not a symlink. Skipping." + ((SKIPPED++)) + else + mkdir -p "$(dirname "$dest")" + ln -s "$src" "$dest" + echo "โœ… Linked: $dest โ†’ $src" + ((CREATED++)) + fi } # --------------------------------------------------------------------------------- ## LINK SYMLINKS # --------------------------------------------------------------------------------- if [ "$DO_LINKS" = true ]; then - if [ "$CONFIRM_MODE" = true ]; then - read -p "โ“ Do you want to create symlinks for your dotfiles? [y/N] " confirm - case "$confirm" in - [Yy]*) ;; # continue below - *) DO_LINKS=false ;; - esac - fi + if [ "$CONFIRM_MODE" = true ]; then + read -p "โ“ Do you want to create symlinks for your dotfiles? [y/N] " confirm + case "$confirm" in + [Yy]*) ;; # continue below + *) DO_LINKS=false ;; + esac + fi fi if [ "$DO_LINKS" = true ]; then - echo "๐Ÿ”— Checking and creating symlinks..." - CREATED=0 - SKIPPED=0 + echo "๐Ÿ”— Checking and creating symlinks..." + CREATED=0 + SKIPPED=0 - link_file "$DOTFILES_DIR/config/fish/config.fish" "$HOME/.config/fish/config.fish" - link_file "$DOTFILES_DIR/config/vim" "$HOME/.vim" - link_file "$DOTFILES_DIR/config/kanata" "$HOME/.config/kanata" - link_file "$DOTFILES_DIR/scripts/bin" "$HOME/.local/bin" + # Modern shell & editor setup + link_file "$DOTFILES_DIR/config/niri/config.kdl" "$HOME/.config/niri/config.kdl" + link_file "$DOTFILES_DIR/config/niri/dms/binds.kdl" "$HOME/.config/niri/dms/binds.kdl" + link_file "$DOTFILES_DIR/config/fish/config.fish" "$HOME/.config/fish/config.fish" + link_file "$DOTFILES_DIR/config/vim" "$HOME/.vim" + link_file "$DOTFILES_DIR/config/kanata" "$HOME/.config/kanata" + link_file "$DOTFILES_DIR/scripts/bin" "$HOME/.local/bin" - echo "" - echo "๐Ÿงพ Summary: $CREATED symlink(s) created or fixed, $SKIPPED skipped." - echo "" + echo "" + echo "๐Ÿงพ Summary: $CREATED symlink(s) created or fixed, $SKIPPED skipped." + echo "" - echo "โœ… Symlink setup complete." - echo "" + echo "โœ… Symlink setup complete." + echo "" fi # --------------------------------------------------------------------------------- ## INSTALL SYSTEM PACKAGES # --------------------------------------------------------------------------------- if [ "$DO_INSTALL" = true ]; then - if [ "$CONFIRM_MODE" = true ]; then - read -p "โ“ Do you want to install system packages? [y/N] " confirm - case "$confirm" in - [Yy]*) ;; # continue below - *) DO_INSTALL=false ;; - esac - fi + if [ "$CONFIRM_MODE" = true ]; then + read -p "โ“ Do you want to install system packages? [y/N] " confirm + case "$confirm" in + [Yy]*) ;; # continue below + *) DO_INSTALL=false ;; + esac + fi fi if [ "$DO_INSTALL" = true ]; then - REQUIRED_PACKAGES=( - # system - fuse3 - # network & download - wget curl ca-certificates gnupg rsync - # core utilities - fish git vim fd-find jq fzf ripgrep tree direnv make bat - ark unzip p7zip-full tar gzip bzip2 xz-utils - # build & dev tools - build-essential valgrind nodejs - # fonts - fonts-noto-core fonts-noto-color-emoji - # desktop portal - xdg-desktop-portal xdg-desktop-portal-gtk - ) - MISSING_PACKAGES=() + # ----------------------------------------------------------------------------- + ## ADD NONFREE REPOS + # ----------------------------------------------------------------------------- + echo "๐Ÿ“ฆ Checking nonfree repositories..." - echo "๐Ÿ” Checking for missing packages..." - echo "" + REPO_PACKAGES=(void-repo-nonfree) - # Check which packages are missing using dpkg - for pkg in "${REQUIRED_PACKAGES[@]}"; do - if ! dpkg -s "$pkg" >/dev/null 2>&1; then - MISSING_PACKAGES+=("$pkg") - fi - done + # Only add multilib-nonfree on x86_64 + if [ "$(uname -m)" = "x86_64" ]; then + REPO_PACKAGES+=(void-repo-multilib-nonfree) + fi - if [ ${#MISSING_PACKAGES[@]} -eq 0 ]; then - echo "โœ… All required packages are already installed." - else - echo "๐Ÿ“ฆ Syncing package index..." - sudo apt update + MISSING_REPOS=() + for repo in "${REPO_PACKAGES[@]}"; do + if ! xbps-query -p pkgver "$repo" >/dev/null 2>&1; then + MISSING_REPOS+=("$repo") + fi + done - echo "๐Ÿ“ฆ Installing missing packages: ${MISSING_PACKAGES[*]}" - sudo apt install -y "${MISSING_PACKAGES[@]}" - fi + if [ ${#MISSING_REPOS[@]} -eq 0 ]; then + echo "โœ… Nonfree repositories already enabled." + else + echo "๐Ÿ“ฆ Enabling repositories: ${MISSING_REPOS[*]}" + sudo xbps-install -Sy "${MISSING_REPOS[@]}" + fi - echo "" - echo "โœ… Package setup complete." - echo "" + echo "" + + # ----------------------------------------------------------------------------- + ## INSTALL REQUIRED PACKAGES + # ----------------------------------------------------------------------------- + REQUIRED_PACKAGES=( + # system & shell + pfetch fuse3 fish-shell + # network & download + wget curl ca-certificates gnupg rsync + # core utilities & CLI tools + git vim fd jq fzf ripgrep tree direnv make bat + ark unzip p7zip tar gzip bzip2 xz kanata gitu + # build & dev tools + alacritty base-devel valgrind tree-sitter-cli go nodejs + ) + + MISSING_PACKAGES=() + + echo "๐Ÿ” Checking for missing packages..." + echo "" + + # Check which packages are missing using xbps-query + for pkg in "${REQUIRED_PACKAGES[@]}"; do + if ! xbps-query -p pkgver "$pkg" >/dev/null 2>&1; then + MISSING_PACKAGES+=("$pkg") + fi + done + + if [ ${#MISSING_PACKAGES[@]} -eq 0 ]; then + echo "โœ… All required packages are already installed." + else + echo "๐Ÿ“ฆ Syncing repository indexes..." + sudo xbps-install -S + + echo "๐Ÿ“ฆ Installing missing packages: ${MISSING_PACKAGES[*]}" + sudo xbps-install "${MISSING_PACKAGES[@]}" + fi + + echo "" + echo "โœ… Package setup complete." + echo "" fi