-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·158 lines (147 loc) · 5.1 KB
/
install.sh
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/bash
# set locale, stops the warnings from perl. (needs fixing)
export LC_ALL="en_GB.UTF-8"
export LANG="en_GB.UTF-8"
export LANGUAGE="en_GB.UTF-8"
# Check to see if nix is already installed.
if [[ -f /nix/receipt.json || -d /nix ]]; then
echo "Looks like Nix is already installed..."
read -r -p "Do you want to continue with the rest of the script, omitting the Nix install? (Y/n): " decision
if [[ $decision != "Y" && $decision != "y" ]]; then
echo "Aborting."
exit 0
fi
else
echo "Looks like Nix has not been installed."
read -r -p "Do you want to install Nix? (Y/n): " decision
if [[ $decision != "Y" && $decision != "y" ]]; then
echo "Aborting."
exit 0
fi
# Proceed with Nix installation
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix/tag/v0.9.0 | sh -s -- install
# source nix
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
fi
echo "You don't need to run the above command, I have already just started the nix-daemon..."
read -r -p "Do you want to continue with package installation? (Y/n): " decision
if [[ $decision != "Y" && $decision != "y" ]]; then
echo "Aborting, done, no packages to install!..."
exit 0
fi
if [[ $(uname -s) =~ "Darwin" ]]; then
read -r -p "We have detected you are running MacOS/Darwin, is this correct? (Y/n): " decision
if [[ $decision != "Y" && $decision != "y" ]]; then
echo "Aborting, something is afoot!..."
exit 0
fi
# continue with MacOS/Darwin packages here.
# (add any packages to install on MacOS/Darwin here, this may just
# be a copy of the ones below, although you likely don't need zsh.
# install packages
echo "Installing MacOS packages..."
sleep 1
nix profile install \
nixpkgs#git \
nixpkgs#kitty \
nixpkgs#neovim \
nixpkgs#tmux \
nixpkgs#stow \
nixpkgs#yarn \
nixpkgs#fzf \
nixpkgs#ripgrep \
nixpkgs#bat \
nixpkgs#gnumake \
nixpkgs#gcc \
nixpkgs#direnv \
nixpkgs#trash-cli \
nixpkgs#nodePackages_latest.bash-language-server \
nixpkgs#yaml-language-server \
nixpkgs#xclip \
nixpkgs#nodejs-18_x \
nixpkgs#nodePackages_latest.prettier \
nixpkgs#shellcheck \
nixpkgs#btop
sleep 2
# stow dotfiles
stow git
stow nvim
stow tmux
stow zsh
stow kitty
fi
if [[ $(uname -s) =~ "Linux" ]]; then
read -r -p "We have detected you are Linux, is this correct? (Y/n): " decision
if [[ $decision != "Y" && $decision != "y" ]]; then
echo "Aborting, something is afoot!..."
exit 0
fi
# Continue with package installation here
echo "Installing Linux packages...(you may receive some warnings about locale, ignore)..."
sleep 3
# install packages specific to Linux here.
nix profile install \
nixpkgs#zsh \
nixpkgs#git \
nixpkgs#neovim \
nixpkgs#tmux \
nixpkgs#stow \
nixpkgs#yarn \
nixpkgs#fzf \
nixpkgs#ripgrep \
nixpkgs#bat \
nixpkgs#gnumake \
nixpkgs#gcc \
nixpkgs#direnv \
nixpkgs#trash-cli \
nixpkgs#nodePackages_latest.bash-language-server \
nixpkgs#yaml-language-server \
nixpkgs#xclip \
nixpkgs#nodejs-18_x \
nixpkgs#nodePackages_latest.prettier \
nixpkgs#shellcheck \
nixpkgs#btop
sleep 2
# stow dotfiles
stow git
stow nvim
stow tmux
stow zsh
fi
# add zsh as a login shell but first check
# if the line already exists. This can happen
# if we run the install script multiple times.
if command -v zsh >/dev/null; then
zsh_path=$(command -v zsh)
# Check if zsh path already exists in /etc/shells
if ! grep -Fxq "$zsh_path" /etc/shells; then
echo "$zsh_path" | sudo tee -a /etc/shells
echo -e "\e[1mZsh path has been added to /etc/shells.\e[0m"
else
echo -e "\e[1mZsh path already exists in /etc/shells.\e[0m"
fi
else
echo -e "\e[1mZsh is not installed.\e[0m"
fi
# Create a symlink of our ~/.bin folder
ln -sf "$HOME/.dotfiles/bin" "$HOME/.bin"
# use zsh as default shell
sudo chsh -s "$(which zsh)" "$USER"
# Pull down Antidote, which is a zsh package manager. (replaces Antibody)
echo "Installing/configuring antidote..."
git clone --depth=1 https://github.com/mattmc3/antidote.git ${ZDOTDIR:-~}/.antidote
# Account for slight difference between linux uname and darwin uname.
if [[ $(uname -s) =~ 'Darwin' ]]; then
chmod +x ~/.antidote/antidote && sed -i "" "1s|.*|#\!$HOME/.nix-profile/bin/zsh|" ~/.antidote/antidote && ln -sf ~/.antidote/antidote ~/.bin/antidote
else
chmod +x ~/.antidote/antidote && sed -i "1s|.*|#\!$HOME/.nix-profile/bin/zsh|" ~/.antidote/antidote && ln -sf ~/.antidote/antidote ~/.bin/antidote
fi
sleep 1
~/.antidote/antidote bundle < ~/.zsh_plugins.txt > ~/.zsh_plugins.sh
# install neovim plugins
echo "You may see some errors below as we try to install the NeoVim plugins, do not be alarmed!"
sleep 2
nvim --headless +PlugInstall +qall
#
echo "Almost done. Please log out and back in again to configure zsh etc."
echo "You may also need to open neovim to complete Plugin installation."