-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
297 lines (243 loc) · 7.28 KB
/
Makefile
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
.PHONY: \
default \
update \
links \
install \
min \
min-update \
min-install \
min-links \
install-yay \
install-aur-packages \
install-packages \
user-fs \
update-zsh-plugins \
update-libs \
init-vim \
update-vim \
update-src \
link-misc \
link-conf \
link-local \
set-shell \
i3 \
rofi \
update-tmux \
save-originals \
rustup \
update-rust
HOST ?= $(shell hostname)
NOW = $(shell date +"%Y-%m-%dT%T")
TIMESTAMP=$(shell date +%s)
VARS = ~/etc/local/$(HOST)/variables.mk
CONF = $(shell ls conf)
LOCAL = $(shell ls local/$(HOST)/conf)
DIRS = \
~/src \
~/lib \
~/mnt \
~/tmp \
~/bin \
~/opt \
~/sbin \
~/var/log \
~/var/vim/undo \
~/.cache/vim/backup \
~/.cache/zsh \
~/backup \
~/.local/share \
~/.config/dunst \
~/.local/share/applications \
~/etc/build
ifneq ("$(wildcard $(VARS))","")
include $(VARS)
endif
default: links update i3 rofi dunst
update: update-zsh-plugins update-libs update-tmux update-vim update-rust
links: link-conf link-misc link-local
install: user-fs \
install-paru \
install-packages \
install-aur-packages \
save-originals \
set-shell \
update-src \
update-libs \
update-zsh-plugins \
~/.tmux/plugins/tpm \
links \
~/.zplug cleanup
min: min-install \
save-originals \
user-fs \
update-libs \
set-shell \
min-links \
~/src/srcery-vim \
~/src/srcery-terminal \
update-zsh-plugins \
init-vim \
~/.tmux/plugins/tpm \
update-tmux \
cleanup
min-update: update-libs update-zsh-plugins update-tmux update-vim
min-install:
xargs sudo apt-get install -y < min_packages.txt
min-links:
stow -R -t ~ -d conf zsh git tmux vim bash nvim
cleanup:
@echo -e "\033[0;33mCleaning up...\033[0m"
-rm -rf ~/etc/build
install-yay: ~/etc/build
@echo -e "\033[0;33mBuilding and installing yay...\033[0m"
-cd ~/etc/build && git clone https://aur.archlinux.org/yay.git
-cd ~/etc/build/yay && makepkg -si --noconfirm --needed
install-paru: ~/etc/build
@echo -e "\033[0;33mBuilding and installing paru...\033[0m"
-cd ~/etc/build && git clone https://aur.archlinux.org/paru.git
-cd ~/etc/build/paru && makepkg -si --noconfirm --needed
add-pacman-repositories:
@echo -e "\033[0;33mAdding pacman repositories...\033[0m"
cat pacman_repositories.txt | sudo tee -a /etc/pacman.conf
install-aur-packages: install-yay
@echo -e "\033[0;33mInstalling AUR packages...\033[0m"
yay -S --needed --noconfirm - < aur_packages.txt
install-packages:
@echo -e "\033[0;33mInstalling packages...\033[0m"
sudo pacman --needed -S - < pacman_packages.txt
# Scaffold user fs structure.
user-fs: $(DIRS)
@echo -e "\033[0;33mCreate user fs...\033[0m"
$(DIRS):
mkdir -p $@
~/.cache/zsh/dirs:
-touch ~/.cache/zsh/dirs
update-zsh-plugins: ~/.zplug
@echo -e "\033[0;33mUpdating zsh plugins...\033[0m"
./scripts/zsh-update.sh
update-libs:
./scripts/git_update.sh ~/lib ~/etc/lib_repositories.txt
init-vim: ~/.vim/autoload/plug.vim
@echo -e "\033[0;33mInitialize Vim...\033[0m"
vim -c "exec InstallAndExit()"
update-vim: ~/.vim/autoload/plug.vim
@echo -e "\033[0;33mUpdating Vim packages...\033[0m"
vim -c "exec UpdateAndExit()"
~/.vim/autoload/plug.vim:
@echo -e "\033[0;33mGetting plugin manager for Vim...\033[0m"
curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
update-src:
@echo -e "\033[0;33mUpdate src...\033[0m"
# ssh-add -l &>/dev/null || ssh-add ~/.ssh/id_rsa
./scripts/git_update.sh ~/src ~/etc/src_repositories.txt
link-misc: ~/scripts ~/colors ~/bin/ftl ~/bin/touchpad-toggle ~/bin/tmain ~/bin/tupd
@echo -e "\033[0;33mSymlinking misc files...\033[0m"
~/scripts: user-fs
-ln -sf $(HOME)/src/scripts $(HOME)
~/colors: user-fs
-ln -sf $(HOME)/src/colors $(HOME)
~/bin/ftl: user-fs
-ln -sf $(HOME)/etc/scripts/ftl.sh $@
~/bin/touchpad-toggle: user-fs update-src
-ln -sf $(HOME)/src/scripts/touchpad-toggle.sh $@
~/bin/tmain: user-fs
-ln -sf $(HOME)/scripts/tmux-main.sh $@
~/bin/tmusic: user-fs
-ln -sf $(HOME)/scripts/tmux-music.sh $@
~/bin/tupd: user-fs
-ln -sf $(HOME)/scripts/tmux-update-window.sh $@
~/bin/tssh: user-fs
-ln -sf $(HOME)/scripts/tmux-ssh.sh $@
link-conf: user-fs
@echo -e "\033[0;33mSymlinking conf...\033[0m"
-stow -R -t ~ -d conf --ignore="md|org|firefox" $(CONF) 2>&1 | grep -v "BUG in find_stowed_path" || true
link-local:
@echo -e "\033[0;33mSymlinking local...\033[0m"
-stow -R -t ~ -d local/$(HOST)/conf $(LOCAL) 2>&1 | grep -v "BUG in find_stowed_path" || true
set-shell:
@echo -e "\033[0;33mSetting shell to zsh...\033[0m"
chsh -s `which zsh`
~/.dircolors: update-libs
-ln -s $(HOME)/lib/LS_COLORS/LS_COLORS $@
# ~/bin/vidir: update-libs
# -ln -s $(HOME)/lib/vidir/bin/vidir $@
~/.i3/config: link-conf ~/etc/local/$(HOST)/variables.mk ~/etc/templates/i3/*.i3
@echo -e "\033[0;33mCreating i3 config...\033[0m"
cd ~/etc/templates/i3 && cat *.i3 > $@
ifdef primary_monitor
@echo "set \$$primary_monitor $(primary_monitor)" >> $@
endif
ifdef secondary_monitor
@echo "set \$$secondary_monitor $(secondary_monitor)" >> $@
endif
ifdef tertiary_monitor
@echo "set \$$tertiary_monitor $(tertiary_monitor)" >> $@
endif
ifdef quaternary_monitor
@echo "set \$$quaternary_monitor $(quaternary_monitor)" >> $@
endif
i3: ~/.i3/config
@echo -e "\033[0;33mReload i3 config...\033[0m"
i3-msg reload
@echo -e "\033[1;32mi3 config reloaded!\033[0m"
dunst: ~/.config/dunst/dunstrc
@echo -e "\033[0;33mCreating dunst config...\033[0m"
~/.config/dunst/dunstrc: ~/etc/templates/dunst/config.dunst ~/etc/local/$(HOST)/variables.mk
@mkdir -p $(@D)
cat ~/etc/templates/dunst/config.dunst > ~/.config/dunst/dunstrc
ifdef font
sed -ri '/\[global\]/a font = $(font)' $@
endif
ifdef dunst_width
sed -ri "/\[global\]/a width = $(dunst_width)" $@
endif
ifdef dunst_height
sed -ri "/\[global\]/a height = $(dunst_height)" $@
endif
ifdef dunst_offset
sed -ri "/\[global\]/a offset = $(dunst_offset)" $@
endif
~/.config/rofi/config.rasi: ~/etc/templates/rofi/config.rofi ~/etc/local/$(HOST)/variables.mk
cat ~/etc/templates/rofi/*.rofi > $@
ifdef bar_height
sed -i '0,/}/{s//\n yoffset: $(bar_height);\n}/}' $@
endif
ifdef font
sed -i '0,/}/{s//\n font: $(font);\n}/}' $@
endif
ifneq ($(and $(rofi_height),$(rofi_width)),)
echo -e "\nwindow {" >> $@
echo " width: $(rofi_width)px;" >> $@
echo " height: $(rofi_height)px;" >> $@
echo "}" >> $@
endif
rofi: ~/.config/rofi/config.rasi
@echo -e "\033[0;33mCreating rofi config...\033[0m"
update-tmux:
@echo -e "\033[0;33mUpdating tmux plugins...\033[0m"
~/.tmux/plugins/tpm/bin/update_plugins all
~/.tmux/plugins/tpm:
@echo -e "\033[0;33mInitialize tmux...\033[0m"
@mkdir -p $(@D)
-@git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm && ~/.tmux/plugins/tpm/bin/install_plugins
save-originals:
mkdir -p ~/backup/original-system-files
-@mv ~/.bash* ~/backup/original-system-files
rustup:
rustup install stable
rustup install nightly
rustup default stable
update-rust:
rustup update
~/bin/bakc: update-src
ln -s ~/src/bakc/bakc.sh ~/bin/bakc
i3wsr:
cargo install i3wsr
~/.zplug:
curl -sL --proto-redir -all,https https://raw.githubusercontent.com/zplug/installer/master/installer.zsh | zsh
~/src/srcery-vim:
@mkdir -p $(@D)
git clone https://github.com/srcery-colors/srcery-vim ~/src/srcery-vim
~/src/srcery-terminal:
@mkdir -p $(@D)
git clone https://github.com/srcery-colors/srcery-terminal ~/src/srcery-terminal