aboutsummaryrefslogtreecommitdiff
path: root/install.sh
blob: 16279eb5f6f48adb496a03398db67c955f9e97ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/env bash

currentDir="$(dirname "$(readlink -f "$0")")"
cd "$currentDir"

## Install necessary desktop packages
source "$currentDir/packages/pkg_desktop.sh"
source "$currentDir/packages/pkg_utils.sh"
sudo pacman -Sy --needed "${pkg_desktop[@]}" "${pkg_utils[@]}"

## Install dev tools
read -rp "Do you wish to install development tools? [y/N]" install_dev_tools
source "$currentDir/packages/pkg_dev_tools.sh"
if [[ $install_dev_tools == y ]]; then
    sudo pacman -S --needed "${pkg_dev_tools[@]}"
fi

## Install optional packages
read -rp "Do you wish to install optional packages? [y/N]" install_optional_pkg
if [[ $install_optional_pkg == y ]]; then
    source "$currentDir/packages/pkg_optional.sh"
    sudo pacman -S --needed "${pkg_optional[@]}"
fi

## Install nvidia drivers
read -rp "Do you wish to install Nvidia drivers? [y/N]" install_nvidia_drivers
if [[ $install_nvidia_drivers == y ]]; then
    source "$currentDir/packages/pkg_nvidia.sh"
    sudo pacman -S --needed "${pkg_nvidia[@]}"
fi


## Install aur packages
read -rp "Do you wish to install aur packages? [y/N]" install_aur_pkg
if [[ $install_aur_pkg == y ]]; then
    ## Install paru if it isn't already installed
    if ! command -v paru >/dev/null 2>&1; then
        echo "Installing paru..."
        git clone https://aur.archlinux.org/paru-bin.git
        cd paru-bin
        makepkg -sri
        cd ..
        rm -rf paru-bin
    else
        echo "Skipping paru (already in PATH)"
    fi
    ## Install aur packages
    source "$currentDir/packages/pkg_aur.sh"
    paru -S --needed  "${pkg_aur[@]}"
fi


## Setup dotfiles
echo "⚠️  WARNING: This will DELETE any conflicting files and replace them with symlinks from this repo."
echo "Make sure you have already backed up all your existing config files (~/.config)"
read -rp "Continue with stow (y/N): " confirm
if [[ "$confirm" =~ ^[Yy]$ ]]; then
    echo "Detecting conflicts..."
    conflicts=$(stow . --no-folding -nv 2>&1 | \
        sed -n 's/.*existing target \(.*\) since neither.*/\1/p')

    if [[ -z "$conflicts" ]]; then
        echo "No conflicts. Running stow normally..."
        stow . --no-folding
        echo "✅ Done."
    else
        echo "These paths conflict and will be removed:"
        printf '  %s\n' $conflicts
        read -rp "Proceed with deleting these files? (y/N): " ok
        if [[ ! "$ok" =~ ^[Yy]$ ]]; then
            echo "Aborted."
        fi

    # Remove conflicts relative to $HOME
    for path in $conflicts; do
        echo "Removing $HOME/$path"
        rm -rf "$HOME/$path"
    done

    echo "Running stow..."
    stow . --no-folding
    echo "✅ Dotfiles stowed with overwrite."
    fi
else
    echo "Aborted stow"
fi


## Setup neovim dotfiles
read -rp "Clone neovim dotfiles as well? (y/N): " confirm
if [[ "$confirm" =~ ^[Yy]$ ]]; then
    echo "Taking backup of neovim config (if already exists)"
    mv ~/.config/nvim{,.bak}
    mv ~/.local/share/nvim{,.bak}
    mv ~/.local/state/nvim{,.bak}
    mv ~/.cache/nvim{,.bak}
    git clone --depth=1 git@github.com:krolyxon/nvim.git ~/.config/nvim
fi

## Change default shell to zsh
if [[ "$SHELL" != "$(which zsh)" ]]; then
    read -rp "Change default shell to ZSH? (y/N): " confirm
    if [[ "$confirm" =~ ^[Yy]$ ]]; then
        echo "Changing default shell to zsh..."
        chsh -s $(which zsh)
    fi
else
    echo "Skipping: zsh is already the default shell"
fi


printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
echo ""
echo "Done! 😊"