-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdev-env.sh
executable file
·220 lines (192 loc) · 5.1 KB
/
dev-env.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#!/usr/bin/env bash
#
# Install all dependencies for dev environment
# Only supports Arch-based distros.
#
# Given the size of this, might just want to write a python
# script at some point.
#
set -e
is_command() {
# Checks to see if the given command (passed as a string argument) exists on
# the system. Returns 0 (success) if the command exists, and 1 if it doesn't.
local check_command="$1"
command -v "${check_command}" >/dev/null 2>&1
}
install_mainline_packages() {
local MAIN_DEPS=(
aspell-en
clang
discord
doas
docker
docker-compose
emacs-nativecomp
fd
gcc
gdb
git-delta
go
gvim
hunspell-en_us
jre-openjdk-headless
lldb
llvm
nodejs
npm
pgformatter
python-pip
python3
reflector
ripgrep
rust
rust-analyzer
texlab
texlive-most
wl-clipboard
wmctrl
)
local PACMAN_FONTS=(
noto-fonts
noto-fonts-emoji
ttf-cascadia-code
ttf-fantasque-sans-mono
ttf-fira-code
ttf-hack
ttf-iosevka-nerd
ttf-jetbrains-mono
)
for package in "${MAIN_DEPS[@]}"; do
pacman -Qm "${package}" 2>/dev/null || sudo pacman -S --noconfirm --needed "${package}"
done
for package in "${PACMAN_FONTS[@]}"; do
sudo pacman -S --noconfirm --needed "$package"
done
}
install_aur_packages() {
local AUR_DEPS=(
google-chrome
onedrive-abraunegg
shellcheck-bin
slack-desktop
spotify
texlive-latexindent-meta
ttf-all-the-icons
visual-studio-code-bin
)
local AUR_FONTS=(
siji-ng
ttf-icomoon-feather
ttf-typicons
)
# Install all AUR packages
for package in "${AUR_DEPS[@]}"; do
pacman -Qm "${package}" 2>/dev/null || yay -S --noconfirm --needed "${package}"
done
for package in "${AUR_FONTS[@]}"; do
pacman -Qm "${package}" || yay -S --noconfirm --needed "${package}"
done
}
install_cargo_packages() {
cargo install --locked --git https://github.com/jarulsamy/dotEngine --profile release
}
setup_doas() {
# Doas config, set this before yay.
# since yay uses doas internally.
DOAS_CONFIG="/etc/doas.conf"
if [ ! -f "$DOAS_CONFIG" ]; then
printf "%s\n" "Setting doas config"
printf "permit :wheel\npermit nopass %s as root\n" "$USER" | /bin/sudo tee "$DOAS_CONFIG"
fi
}
setup_vim() {
# Install all the vim goodness (sweet, sweet coconut oil).
YCM_DIR="${HOME}/.vim/plugged/YouCompleteMe"
if [ ! -f "${YCM_DIR}/installed" ]; then
vim -c ":PlugInstall | :qa"
"${YCM_DIR}/install.py" --all --verbose
touch "${HOME}/.vim/plugged/YouCompleteMe/installed"
printf "Installed Vim plugins and YCM\n"
fi
}
setup_emacs() {
# Install doom emacs (Evil >:D)
if [ ! -f "$HOME/.emacs.d/bin/doom" ]; then
rm -rf "$HOME/.emacs.d"
git clone --depth 1 https://github.com/hlissner/doom-emacs "$HOME/.emacs.d"
"$HOME/.emacs.d/bin/doom" install --no-config --env --install --fonts --force
# Fix missing personal dictionary directory.
ispell_dir="$HOME/.emacs.d/.local/etc/ispell"
if [ ! -d "$ispell_dir" ]; then
mkdir -p "$ispell_dir"
printf "personal_ws-1.1 en 0\n" >"${ispell_dir}/.pws"
fi
printf "Installed Doom Emacs\n"
else
"$HOME/.emacs.d/bin/doom" sync
fi
}
setup_gnome() {
if is_command gsettings; then
favorite_apps="['firefox.desktop', 'org.gnome.Nautilus.desktop', 'kitty.desktop', 'spotify.desktop', 'emacs.desktop', 'vim.desktop', 'visual-studio-code.desktop', 'discord.desktop', 'slack.desktop']"
gsettings set org.gnome.shell favorite-apps "$favorite_apps"
dconf load / <"$HOME/.dotfiles/dconf/custom-shortcuts.ini"
printf "Loaded custom Gnome settings\n"
fi
# Set capslock to escape
gsettings set org.gnome.desktop.input-sources xkb-options "['caps:escape']"
}
setup_fonts() {
# Assume the fonts directory is where it should be.
fonts="$HOME/.dotfiles/fonts"
fontsDest="$HOME/.local/share/fonts"
# Ensure the fonts directory is where it should be.
if [ -d "$fonts" ]; then
# Ensure dest exists
mkdir -p "${fontsDest}"
# Copy font files over
find "${fonts}/" -mindepth 1 -maxdepth 1 -exec cp -r {} "${fontsDest}/" ';'
fc-cache 2>/dev/null 1>&2 -f -v
else
printf "Can't find source fonts directory.\n"
fi
}
setup_reflector() {
sudo cp "$HOME/.dotfiles/reflector/reflector.conf" /etc/xdg/reflector/reflector.conf
sudo systemctl enable --now reflector.timer
printf "Syncing mirrors...\n"
sudo systemctl start reflector.service
}
setup_misc() {
# Misc
sudo usermod -aG docker "$USER"
printf "Added %s to group 'docker'\nLogout and log back in for this to take affect.\n" "$USER"
# Ignore changes to yay's config file. It refuses to keep envvars for the paths.
git update-index --skip-worktree .config/yay/config.json
}
# General validation
if ! is_command pacman; then
printf "OS distribution not supported\n"
exit 1
fi
if ! is_command yay; then
printf "Please install yay first: https://aur.archlinux.org/packages/yay\n"
exit 1
fi
# Ensure we are in the right place
EXPECTED_DIR="$HOME/.dotfiles"
if [ ! "${PWD}" == "$EXPECTED_DIR" ]; then
printf "Ensure .dotfiles is cloned to '%s'\n" "$EXPECTED_DIR"
printf "Also ensure your CWD is '%s'\n" "$EXPECTED_DIR"
exit 1
fi
setup_doas
install_mainline_packages
install_aur_packages
install_cargo_packages
setup_vim
setup_emacs
setup_gnome
setup_fonts
setup_reflector
setup_misc