-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
158 lines (114 loc) · 4.01 KB
/
Makefile
File metadata and controls
158 lines (114 loc) · 4.01 KB
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
# -------- Macros ---------
gnu_ln := $(shell 2>&1 >/dev/null ln --help; echo $$?)
define symlink-dir
$2: | $(dir $2)
ifeq ($(gnu_ln),0)
ln -srTf -- $1 $$@
else
@rm -rvf -- $$@
ln -sf -- $$(abspath $1) $$@
endif
endef
define symlink-file
$2:
ifeq ($(gnu_ln),0)
ln -srTf -- $1 $$@
else
@rm -vf -- $$@
ln -sf -- $$(abspath $1) $$@
endif
endef
# ---------- Nix ----------
.PHONY: nix
nix: /nix ## Install Nix
/nix:
curl -fsSL https://install.determinate.systems/nix | sh -s -- install
# ---------- Zsh ----------
# generate list of Zsh dot files based on contents of zsh/ directory
# e.g. ~/.zshrc ~/.zprofile ...
zdotfiles := $(foreach f,$(wildcard zsh/*),~/.$(notdir $(f)))
.PHONY: zim
zim: $(zdotfiles)
zim: ~/.zim/modules/asciiship/asciiship.zsh-theme
zim: ## Install the Zim Zsh configuration framework
~/.zim:
@rm -vf -- $(zdotfiles)
curl -fsS https://raw.githubusercontent.com/zimfw/install/master/install.zsh | zsh
rm -rf $@/modules/asciiship
@rm -vf -- $(zdotfiles)
# Zsh dot files must be installed *after* Zim itself, otherwise the installation
# gets aborted prematurely with the message "Zim already installed".
$(zdotfiles): | ~/.zim
ifeq ($(gnu_ln),0)
ln -srTf -- $(subst .,zsh/,$(notdir $@)) $@
else
@rm -vf -- $@
ln -sf -- $(abspath $(subst .,zsh/,$(notdir $@))) $@
endif
~/.zim/modules/asciiship/asciiship.zsh-theme:
zsh -ic 'zimfw install'
# ---------- Git ----------
.PHONY: git
git: ~/.gitconfig ## Configure the Git revision control system
$(eval $(call symlink-file,gitconfig,~/.gitconfig))
# -------- WezTerm --------
# ncurses uses the two-character hexadecimal form as the intermediate TERMINFO
# directory tree level on macOS.
# https://invisible-island.net/ncurses/man/term.5.html#h3-Mixed-case-Terminal-Names
terminfo_w := $(if $(filter Darwin,$(shell uname -s)),77,w)
.PHONY: wezterm
wezterm: ~/.config/wezterm
wezterm: ~/.terminfo/$(terminfo_w)/wezterm
wezterm: ~/.wezterm.sh
wezterm: ## Set up the WezTerm terminal emulator and its shell integration
$(eval $(call symlink-dir,wezterm,~/.config/wezterm))
~/.terminfo/$(terminfo_w)/wezterm:
$(eval TMPFILE := $(shell mktemp))
curl -fsSo $(TMPFILE) https://raw.githubusercontent.com/wez/wezterm/main/termwiz/data/wezterm.terminfo
tic -x $(TMPFILE)
rm $(TMPFILE)
~/.wezterm.sh:
curl -fsSo $@ https://raw.githubusercontent.com/wez/wezterm/main/assets/shell-integration/wezterm.sh
# -------- Ghostty --------
.PHONY: ghostty
ghostty: ~/.config/ghostty ## Set up the Ghostty terminal emulator
$(eval $(call symlink-dir,ghostty,~/.config/ghostty))
# -------- Neovim ---------
.PHONY: nvim clean-nvim
nvim: ~/.config/nvim ## Configure the Neovim text editor
~/.config/:
@mkdir $@
$(eval $(call symlink-dir,nvim,~/.config/nvim))
clean-nvim: ## Delete the Neovim state and caches
@rm -rvf ~/.local/share/nvim ~/.local/state/nvim ~/.cache/nvim ~/.config/nvim
# ---------- Vim ----------
.PHONY: vim
vim: ~/.vimrc ## Configure the Vim text editor
$(eval $(call symlink-file,vimrc,~/.vimrc))
# -------- direnv ---------
.PHONY: direnv
direnv: ~/.config/direnv ## Set up direnv
$(eval $(call symlink-dir,direnv,~/.config/direnv))
# ---------- bat ----------
.PHONY: bat
bat: ~/.config/bat ## Set up bat
$(eval $(call symlink-dir,bat,~/.config/bat))
# -------- Wayland --------
.PHONY: wayland
wayland: ~/.config/niri ## Set up the Wayland compositor (Niri)
wayland: ~/.config/waybar
wayland: ~/.config/swaync
$(eval $(call symlink-dir,wayland/niri,~/.config/niri))
$(eval $(call symlink-dir,wayland/waybar,~/.config/waybar))
$(eval $(call symlink-dir,wayland/swaync,~/.config/swaync))
# --------- Misc ----------
.DEFAULT_GOAL := help
.PHONY: help
help:
# source: https://github.com/jessfraz/dotfiles/blob/master/Makefile
# Results are prefixed with the file name when MAKEFILE_LIST has multiple
# values, so we need to additionally handle that case.
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| sort \
| awk 'BEGIN {FS = ":"}; {if (NF < 3) {$$3 = $$2; $$2 = $$1}; print $$2":" $$3}' \
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'