-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMakefile
279 lines (249 loc) · 9.69 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
SHELL := /bin/bash
DOTFILES := $(PWD)
OSTYPE := $(shell uname -s)
ARCHITECTURE := $(shell uname -m)
DEVNUL := /dev/null
WHICH := which
PATH := $(PATH):/usr/local/bin:/usr/local/sbin:/usr/bin:$(HOME)/bin:/$(HOME)/.local/bin:$(HOME)/.local/nodejs/bin:$(HOME)/miniforge3/bin
ifeq ($(ARCHITECTURE), arm64)
DOCKER_BUILD_CMD := build --platform linux/amd64 --progress plain --rm
PATH := $(PATH):/opt/homebrew/bin:/opt/homebrew/sbin
else
DOCKER_BUILD_CMD := build --progress plain --rm
endif
ifeq ($(OSTYPE), Darwin)
PYOS := MacOSX
else
PYOS := $(OSTYPE)
endif
DEFAULT_GOAL := help
.PHONY: macos
macos: sudo directories homebrew _macos _terminal zsh python misc nvim _git node
@$(SHELL) $(DOTFILES)/autoloaded/switch_zsh
@zsh -i -c "fast-theme free"
@compaudit | xargs chmod g-w
.PHONY: linux
linux: sudo directories _linux _git zsh python misc node nvim
@$(SHELL) $(DOTFILES)/autoloaded/switch_zsh
.PHONY: minimal
minimal: directories _linux _git zsh python misc node nvim
.PHONY: help
help:
@echo "#######################################################################"
@printf "%s\n" "Targets:"
@grep -E '^[a-zA-Z0-9_-]+:.*' Makefile \
| grep -v 'help:' \
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m %-15s\033[0m %s\n", $$1, $$2}' \
| sed 's/:$///g'
@echo "#######################################################################"
.PHONY: sudo
sudo:
@echo -e "\033[1m\033[34m==> Installation with sudo required\033[0m"
sudo -v
@while true; do sudo -n true; sleep 1200; kill -0 "$$" || exit; done 2>/dev/null &
.PHONY: homebrew
homebrew:
@echo -e "\033[1m\033[34m==> Installing brew if not already present\033[0m"
ifeq ($(ARCHITECTURE), arm64)
@echo -e "\033[1m\033[32m==> Installing rosetta for non-native apps \033[0m"
@if [ ! -d "/usr/libexec/rosetta" ]; then softwareupdate --install-rosetta --agree-to-license; fi
endif
ifeq ($(shell ${WHICH} brew 2>${DEVNUL}),)
@$(SHELL) -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
endif
@echo -e "\033[1m\033[34m==> Installing brew formulas\033[0m"
@brew bundle --file="$(DOTFILES)/Brewfile --no-lock"
@brew cleanup
-brew doctor
.PHONY: python
CONDA_RELEASE := Miniforge3-$(PYOS)-$(ARCHITECTURE)
CONDA_HOME := $(HOME)/miniforge3
python:
ifeq "$(wildcard $(CONDA_HOME))" ""
@echo -e "\033[1m\033[34m==> Downloading $(CONDA_RELEASE) ...\033[0m"
@curl -fsSLO https://github.com/conda-forge/miniforge/releases/latest/download/$(CONDA_RELEASE).sh
@bash "$(CONDA_RELEASE).sh" -b -p $(CONDA_HOME)
@rm "$(CONDA_RELEASE).sh"
endif
@conda init "$(shell basename ${SHELL})"
@conda env update --file $(DOTFILES)/python/environment.yaml
@$(HOME)/miniforge3/bin/pip install flax scipy
ifeq ($(shell ${WHICH} ipython 2>${DEVNUL}),)
@ipython -c exit && ln -sfv $(DOTFILES)/python/ipython_config.py $(HOME)/.ipython/profile_default/
endif
.PHONY: misc
misc:
@echo -e "\033[1m\033[34m==> Installing misc\033[0m"
ifeq ($(shell ${WHICH} fzf 2>${DEVNUL}),)
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf; ~/.fzf/install --bin
endif
@ln -sfv $(DOTFILES)/wgetrc $(HOME)/.wgetrc
@ln -sfv $(DOTFILES)/curlrc $(HOME)/.curlrc
@ln -sfv $(DOTFILES)/tmux/tmux.conf $(HOME)/.tmux.conf
@ln -sfv $(DOTFILES)/latexmkrc $(HOME)/.latexmkrc
@ln -sfv $(DOTFILES)/btop $(HOME)/.config/
.PHONY: zsh
zsh:
@echo -e "\033[1m\033[34m==> Installing zsh and tools\033[0m"
@ln -sfv $(DOTFILES)/zsh/zshrc $(HOME)/.zshrc
@ln -sfv $(DOTFILES)/zsh/zlogin $(HOME)/.zlogin
@ln -sfv $(DOTFILES)/zsh/zshenv $(HOME)/.zshenv
@ln -sfv $(DOTFILES)/zsh/zprofile $(HOME)/.zprofile
@mkdir -p $(HOME)/.zsh-complete && rg --generate complete-zsh > $(HOME)/.zsh-complete/_rg
@. $(HOME)/.zshrc
.PHONY: node
node:
@echo -e "\033[1m\033[34m==> Installing node and npm packages\033[0m"
ifeq ($(shell ${WHICH} node 2>${DEVNUL}),)
bash $(DOTFILES)/scripts/nodejs.sh
endif
@npm i --location=global npm@latest
@npm i --location=global eslint
@npm i --location=global neovim
.PHONY: nvim
nvim:
@echo -e "\033[1m\033[34m==> Installing nvim dependencies\033[0m"
@nvim "+call mkdir(stdpath('config'), 'p')" +qall
@rm -rfv $(HOME)/.config/nvim
@touch $(HOME)/.localnvim.lua
@ln -sfv $(DOTFILES)/nvim $(HOME)/.config
@nvim --headless "+Lazy! sync" +qa
_git:
@echo -e "\033[1m\033[34m==> Installing stuff for git\033[0m"
@curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o $(HOME)/.git-completion.bash
@ln -sfv $(DOTFILES)/git/gitconfig $(HOME)/.gitconfig
@ln -sfv $(DOTFILES)/git/gitignore $(HOME)/.gitignore
.PHONY: after
after: _terminal
@echo -e "\033[1m\033[34m==> \033[0m"
@bash $(DOTFILES)/git/setup.sh
@if [ "$(OSTYPE)" == "Linux" ]; then bash $(DOTFILES)/linux/apt.sh "desktop"; fi
@nvim -i NONE -u $(DOTFILES)/nvim/init.vim -c "TSUpdate" -c "quitall"
ifeq ($(OSTYPE), Darwin)
@brew services start sketchybar
endif
directories:
@echo -e "\033[1m\033[34m==> Creating directories\033[0m"
mkdir -p $(HOME)/config
mkdir -p $(HOME)/.zsh
mkdir -p $(HOME)/.config/htop
mkdir -p $(HOME)/tmp
mkdir -p $(HOME)/.Trash
mkdir -p $(HOME)/Downloads
mkdir -p $(HOME)/bin
.PHONY: micro
micro: _backup _bash
ln -sfv $(DOTFILES)/bash/tmux.conf $(HOME)/.tmux.conf
ln -sfv $(DOTFILES)/bash/vimrc $(HOME)/.vimrc
ln -sfv $(DOTFILES)/htop/server $(HOME)/.htoprc
mkdir -p ~/.Trash
_bash:
ln -sfv $(DOTFILES)/bash/bash_profile $(HOME)/.bash_profile;
ln -sfv $(DOTFILES)/bash/bashrc $(HOME)/.bashrc;
ln -sfv $(DOTFILES)/bash/bash_prompt $(HOME)/.bash_prompt;
ln -sfv $(DOTFILES)/bash/bash_logout $(HOME)/.bash_logout;
ln -sfv $(DOTFILES)/bash/bash_aliases ~/.bash_aliases
ln -sfv $(DOTFILES)/bash/bash_functions ~/.bash_functions
_backup:
mkdir -p $(HOME)/old_dots
mv $(HOME)/.bash* $(HOME)/old_dots/ || echo "No .bash* found"
mv $(HOME)/.profile $(HOME)/old_dots/ || echo "No .profile found"
mv $(HOME)/.vimrc $(HOME)/old_dots/ || echo "No .vimrc found"
mv $(HOME)/.tmux.conf $(HOME)/old_dots/ || echo "No .tmux.conf found"
mv $(HOME)/.htoprc $(HOME)/old_dots/ || echo "No .htoprc found"
.PHONY: _linux
_linux:
@echo -e "\033[1m\033[34m==> Installing linux basis\033[0m"
@mkdir -p $(HOME)/bin
@mkdir -p $(HOME)/.local/bin
@mkdir -p $(HOME)/Uploads
if [ -z $(NOSUDO) ]; then bash $(DOTFILES)/linux/apt.sh "default"; fi
@ln -sfv $(DOTFILES)/htop/server $(HOME)/.config/htop/htoprc
ifeq ($(shell ${WHICH} nvim 2>${DEVNUL}),)
if [ -z $(NOSUDO) ]; then bash $(DOTFILES)/scripts/nvim.sh "src"; else bash $(DOTFILES)/scripts/nvim.sh "binary"; fi
endif
ifeq ($(shell ${WHICH} tree-sitter 2>${DEVNUL}),)
@bash $(DOTFILES)/scripts/tree-sitter.sh
endif
ifeq ($(shell ${WHICH} nvidia-smi 2>${DEVNUL}),)
@conda install nvitop -n base -y
endif
.PHONY: _macos
_macos:
@echo -e "\033[1m\033[34m==> Configure macos and applications\033[0m"
if [ -n "$(xcode-select -p)" ]; then sudo xcode-select --install; sudo xcodebuild -license accept; fi
@mkdir -p $(HOME)/screens
@bash $(DOTFILES)/macos/main.bash
@ln -sfv $(DOTFILES)/sketchybar $(HOME)/.config/sketchybar
@curl -L https://github.com/kvndrsslr/sketchybar-app-font/releases/download/v2.0.29/sketchybar-app-font.ttf -o $(HOME)/Library/Fonts/sketchybar-app-font.ttf
@ln -sfv $(DOTFILES)/aerospace.toml $(HOME)/.aerospace.toml
@ln -sfv $(DOTFILES)/skhd $(HOME)/.config/skhd
ifeq ($(shell ${WHICH} airport 2>${DEVNUL}),)
@sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/local/bin/airport
endif
@zsh $(DOTFILES)/scripts/sioyek.sh
@ln -sfv $(DOTFILES)/sioyek $(HOME)/.config/sioyek
@swift package completion-tool generate-zsh-script > $(HOME)/.zsh/completion/_swift
ifeq ($(shell ${WHICH} sourcekit-lsp 2>${DEVNUL}),)
@bash $(DOTFILES)/scripts/sourcekit-lsp.sh
endif
ifeq ($(shell ${WHICH} battery 2>${DEVNUL}),)
@curl -s https://raw.githubusercontent.com/actuallymentor/battery/main/setup.sh | bash
@battery maintain 80
endif
@ln -sfv $(DOTFILES)/mpv $(HOME)/.config/mpv
.PHONY: _terminal
_terminal:
ifeq ($(shell ${WHICH} ghostty 2>${DEVNUL}),)
@wget https://github.com/ghostty-org/ghostty/releases/download/tip/Ghostty.dmg && open Ghostty.dmg
endif
@ln -sfv $(DOTFILES)/ghostty $(HOME)/.config/ghostty
@ln -sfv $(DOTFILES)/htop/personal $(HOME)/.config/htop/htoprc
.PHONY: check
check:
@nvim -i NONE -c "checkhealth"
.PHONY: benchmark
benchmark:
@echo -e "\033[1m\033[34m==> nvim startuptime clean\033[0m"
@nvim --startuptime startup.log --clean "+qall" && cat startup.log | sort --key=2 --reverse && rm -f startup.log
@echo -e "\033[1m\033[34m==> nvim startuptime with all plugins\033[0m"
@nvim --startuptime startup.log "+qall" && cat startup.log | sort --key=2 --reverse && rm -f startup.log
@echo -e "\033[1m\033[34m==> zsh startuptime\033[0m"
@zsh $(DOTFILES)/autoloaded/bench_zsh
.PHONY: format
format:
@stylua -v -f $(DOTFILES)/.stylua.toml $$(find $(DOTFILES) -type f -name '*.lua')
.PHONY: uninstall
uninstall:
rm $(HOME)/.zshrc
rm $(HOME)/.zshenv
rm $(HOME)/.zprofile
rm $(HOME)/.tmux.conf
rm $(HOME)/.wgetrc
rm $(HOME)/.curlrc
rm $(HOME)/.latexmkrc
rm $(HOME)/.gitignore
rm $(HOME)/.gitconfig
rm $(HOME)/.config/htop
rm $(HOME)/.config/btop
rm $(HOME)/.config/nvim
ifeq ($(OSTYPE), Darwin)
rm $(HOME)/.aerospace.toml
rm $(HOME)/.config/skhd
rm $(HOME)/.config/sketchybar
rm $(HOME)/.config/sioyek
sudo battery uninstall
endif
.PHONY: test
test:
@echo "Testing linux installation on ${OSTYPE}"
ifeq ($(NOSUDO), 1)
@docker $(DOCKER_BUILD_CMD) -t dotfiles ${PWD} -f $(DOTFILES)/docker/Dockerfile;
@docker run -it --rm --name maketest -d dotfiles:latest;
@docker exec -it maketest /bin/bash -c "make NOSUDO=$(NOSUDO) minimal";
else
@docker $(DOCKER_BUILD_CMD) -t dotfiles_sudo ${PWD} -f $(DOTFILES)/docker/sudoer.Dockerfile;
@docker run -it --rm --name maketest_sudo -d dotfiles_sudo:latest;
@docker exec -it maketest_sudo /bin/bash -c "make linux";
endif
@echo "Container can now be shut down"