-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
107 lines (90 loc) · 3.69 KB
/
Copy pathMakefile
File metadata and controls
107 lines (90 loc) · 3.69 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
UNAME := $(shell uname -s)
# Use --no-folding so every directory under a package becomes a real
# directory in $HOME containing individual file symlinks, rather than
# a single directory-level symlink. This keeps runtime writes (fish's
# fish_variables, fisher plugins' conf.d/, etc.) inside $HOME instead
# of silently propagating into the repo source via a folded symlink.
# Edits to tracked files still go through their per-file symlink to
# the repo source as before.
STOW := stow --no-folding
.DEFAULT_GOAL := install
# Every target in this file is phony — all real work lives in script/
# and this Makefile is just a dispatcher. If you add a new target,
# list it in .PHONY below.
.PHONY: install install-darwin install-codespaces stow-common
.PHONY: setup-git-config regen-git-config
.PHONY: brew fisher mise doctor test clean
# Dispatcher is explicitly serial. Parallel `make -j` on overlapping stow
# packages would race during directory folding, and none of this benefits
# from parallelism anyway.
.NOTPARALLEL:
# Platform-conditional prerequisites, composed at parse time. Under
# .NOTPARALLEL, prerequisites run left-to-right in the order listed,
# so `install`'s chain is: setup-git-config → stow-common → extras.
EXTRA_INSTALL :=
ifeq ($(UNAME),Darwin)
EXTRA_INSTALL += install-darwin
endif
ifneq ($(CODESPACES),)
EXTRA_INSTALL += install-codespaces
endif
install: setup-git-config stow-common $(EXTRA_INSTALL)
stow-common:
./script/stow-package common
# Assumes setup-git-config + stow-common have already run (i.e. was
# invoked via `make install`). Safe to re-run as a standalone repair
# workflow — the script is idempotent.
install-darwin:
./script/install-darwin
# Assumes setup-git-config has already run. Stows the codespaces
# package and runs the tool installer.
install-codespaces:
./script/stow-package codespaces
./script/install-codespace-tools
# Render templates/git-config.tmpl into ~/.config/git/config. Prompts
# for identity on first run; silent thereafter. See the script for
# details.
setup-git-config:
./script/setup-git-config
regen-git-config: setup-git-config
brew:
brew bundle --global
# Bootstrap fisher if missing, then update plugins. Matches the old
# run_onchange_after_30-fisher-update.sh.tmpl. No-op if fish is absent.
fisher:
@if command -v fish >/dev/null 2>&1; then \
fish -c 'curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install jorgebucaran/fisher && fisher update'; \
else \
echo "fish not on PATH; skipping"; \
fi
# Trust mise config and install all runtimes. No-op if mise is absent.
# The guard must be a single if/then/else: an `|| { exit 0; }` on a
# separate recipe line only exits the subshell, and Make proceeds to
# the next line and fails.
mise:
@if command -v mise >/dev/null 2>&1; then \
mise trust && mise install; \
else \
echo "mise not on PATH; skipping"; \
fi
doctor:
./script/doctor
# Static check every script, then run the functional test suite.
# shellcheck is cheap — run it first so a lint failure short-circuits
# before we spin up mktemp sandboxes.
test:
shellcheck -x script/setup script/setup-git-config script/stow-package script/install-darwin script/doctor script/install-codespace-tools script/test
./script/test
# Uninstall all stowed packages from $HOME. Does NOT delete the repo,
# the generated ~/.config/git/config, or ~/.config/dotfiles/identity.env.
# Leading `-` tolerates `stow -D` on a package that wasn't previously
# stowed (modern stow is a no-op in that case, but older versions and
# some edge cases error).
clean:
-$(STOW) -D -t $$HOME common
ifeq ($(UNAME),Darwin)
-$(STOW) -D -t $$HOME darwin
endif
ifneq ($(CODESPACES),)
-$(STOW) -D -t $$HOME codespaces
endif